On Jun 21, 2016 11:12 AM, "INADA Naoki" <songofaca...@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 intermediate step. 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.
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com