[Python-Dev] Compact ordered dict is not ordered for split table. (was: PEP XXX: Compact ordered dict
leewangzhong+python at gmail.com
Sat Jun 25 19:40:08 EDT 2016
On Jun 21, 2016 11:12 AM, "INADA Naoki" <songofacandy at gmail.com> wrote:
> I'm sorry, but I hadn't realized which compact ordered dict is
> not ordered for split table.
> For example:
> >>> class A:
> ... ...
> >>> a = A()
> >>> b = A()
> >>> a.a = 1
> >>> a.b = 2
> >>> b.b = 3
> >>> b.a = 4
> >>> a.__dict__.items()
> dict_items([('a', 1), ('b', 2)])
> >>> b.__dict__.items()
> dict_items([('a', 4), ('b', 3)])
> This doesn't affects to **kwargs and class namespace.
> But if we change the language spec to dict preserves insertion order,
> this should be addressed.
Is that really how it works? From my understanding of PEP 412, they should
have different keysets, because one diverged in keys from the other at an
Another idea (though it has several issues and seems like a step backward):
a split-table dict can have a separate iteration list, indexing into the
entry table. There are ways to share iteration lists, and make it so that
adding the same keys in the same order each time results in the same
iteration list each time, but this costs overhead. There might be ways of
reducing the overhead, or the overhead might be replacing bigger overhead,
but we should decide if the behavior is what we want in the first place.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev