On 21 June 2016 at 10:18, Guido van Rossum <gu...@python.org> wrote: > On Tue, Jun 21, 2016 at 10:12 AM, Eric Snow <ericsnowcurren...@gmail.com> > wrote: >> >> On Mon, Jun 20, 2016 at 12:31 PM, Nikita Nemkin <nik...@nemkin.ru> wrote: >> > Right. Ordered by default is a very serious implementation constraint. >> > It's only superior in a sense that it completely subsumes/obsoletes >> > PEP 520. >> >> Just to be clear, PEP 520 is more than just OrderedDict-by-default. >> In fact, the key point is preserving the definition order, which the >> PEP now reflects better. Raymond's compact dict would only provide >> the ordered-by-default part and does nothing to persist the definition >> order like the PEP specifies. > > > Judging from Inada's message there seems to be some confusion about how well > the compact dict preserves order (personally I think if it doesn't guarantee > order after deletions it's pretty useless). > > Assuming it preserves order across deletions/compactions (like IIUC > OrderedDict does) isn't that good enough for any of the use cases > considered? It would require a delete+insert to change an item's order. If > we had had these semantics in the language from the start, there would have > been plenty uses of this order, and I suspect nobody would have considered > asking for __definition_order__.
RIght, if *tp_dict itself* on type objects is guaranteed to be order-preserviing, then we don't need to do anything except perhaps provide a helper method or descriptor on type that automatically filters out the dunder-attributes, and spell out the type dict population order for: - class statements (universal) - types.new_class (universal) - calling type() directly (universal) - PyType_Ready (CPython-specific) - PyType_FromSpec (CPython-specific) Something that isn't currently defined in PEP 520, and probably should be regardless of whether the final implementation is an order preserving tp_dict or a new __definition_order__ attribute, is where descriptors implicitly defined via __slots__ will appear relative to other attributes. Regards, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ 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