Hi all,

The all-ordered-dicts branch is not quite ready for merging, but
getting there. In one word, it makes all dicts ordered by default, by
a subtle change of the internal model which also makes them *more*
compact.

An annoying detail is the OrderedDict subclass.  We can simplify it a
lot in PyPy, but not completely remove it.  It adds a few methods like
popitem(last=False) or __reversed__() which are not available on the
base class, and it has a different notion of equality (two
OrderedDicts are equal only if they store items in the same order).
Moreover, it's still useful to have a class OrderedDict in PyPy, if
only to say "I really want this dict to be ordered and I want a
CPython-compatible way to express that".

One annoyance is what to do with iteration over OrderedDicts.  The
CPython logic doesn't raise RuntimeError for concurrent modifications.
In fact it doesn't care at all: it gives more or less what we could
reasonably expect in simple cases (like not deleting items, only
adding new ones).  Of course in less simple cases it gives nonsense or
crashes obscurely, like after you deleted the item most recently
returned by an iterator.

What should we do?  We can (1) raise RuntimeError as soon as any
change is detected, like dict, and propagate this to offending
applications; (2) write some slightly different approximation of "what
you'd expect"; or (3) come up with a sane and exact definition of what
to expect and implement that; or (4) find some hack that happens to
give the same result as CPython in the cases where CPython's result
makes sense, but not necessarily in all cases.

Right now the branch implements 2, but I think either 1 or 3 (but not
4) would be a better idea.  Thoughts?


A bientôt,

Armin.
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to