[pypy-dev] Difference to CPython (Maybe a bug in PyPy)
armin.rigo at gmail.com
Fri Oct 12 12:28:19 EDT 2018
On Fri, 12 Oct 2018 at 17:00, Wiener, Markus
<Markus.Wiener at 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.
More information about the pypy-dev