Difference to CPython (Maybe a bug in PyPy)

Hello, i found (maybe) a bug in PyPy. Try:
python python_vs_pypy.py
and
pypy python_vs_pypy.py
Regards, Markus Wiener

Hi, On Fri, 12 Oct 2018 at 17:00, Wiener, Markus <Markus.Wiener@rwth-aachen.de> wrote:
i found (maybe) a bug in PyPy.
Your code is relying on an explicitly undefined behavior described for dicts in https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects . The same applies to sets, although I'm not sure it's as clearly spelled out as for dicts. Specifically, you cannot mutate the set ``a`` in the middle of a loop ``for j in a``. In fact, I think that if your code was written using dicts instead of sets, then its behavior would change in CPython 3.6 because dicts are ordered there. Sets are not---as far as I know (and I guess I should say "not yet"), so CPython 3.6 didn't change for your exact code. But PyPy's sets are ordered, and gives different results. A bientôt, Armin.

Hi, On Fri, 12 Oct 2018 at 17:00, Wiener, Markus <Markus.Wiener@rwth-aachen.de> wrote:
i found (maybe) a bug in PyPy.
Your code is relying on an explicitly undefined behavior described for dicts in https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects . The same applies to sets, although I'm not sure it's as clearly spelled out as for dicts. Specifically, you cannot mutate the set ``a`` in the middle of a loop ``for j in a``. In fact, I think that if your code was written using dicts instead of sets, then its behavior would change in CPython 3.6 because dicts are ordered there. Sets are not---as far as I know (and I guess I should say "not yet"), so CPython 3.6 didn't change for your exact code. But PyPy's sets are ordered, and gives different results. A bientôt, Armin.
participants (2)
-
Armin Rigo
-
Wiener, Markus