On 7 June 2016 at 16:03, Raymond Hettinger <raymond.hettin...@gmail.com> wrote: > >> On Jun 7, 2016, at 10:51 AM, Eric Snow <ericsnowcurren...@gmail.com> wrote: >> >> This PEP changes the default class definition namespace to ``OrderedDict``. > > I think this would be a nice improvement. > >> Furthermore, the order in which the attributes are defined in each class >> body will now be preserved in ``type.__definition_order__``. This allows >> introspection of the original definition order, e.g. by class decorators. > > I'm unclear on why this would be needed. Wouldn't the OrderedDict be > sufficient for preserving definition order?
By the time decorators run, the original execution namespace is no longer available - the contents have been copied into the class dict, which will still be a plain dict (and there's a lot of code that calls PyDict_* APIs on tp_dict, so replacing the latter with a subclass is neither trivial nor particularly safe in the presence of extension modules). Cheers, 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