[New-bugs-announce] [issue24254] Make class definition namespace ordered by default
report at bugs.python.org
Thu May 21 07:34:48 CEST 2015
New submission from Eric Snow:
Here's a work-in-progress patch that uses OrderedDict as the default class definition namespace (instead of dict). While the actual class namespace is a dict, the definition order is preserved on a new attribute on class objects: __definition_order__. This is useful for cases such as class decorators that would make use of the definition order to post-process the class. This is something that Guido okay'ed a while back.
It may be a stretch to get this into 3.5, but the final change should be pretty small. It also depends on the C implementation of OrderedDict (see issue #16991) which has not landed and may not make it in time.
Note that the patch is still a bit buggy, partly due to bugs in the C OrderedDict patch. Also, the attached patch is based off the C OrderedDict patch, so I expect reitveld won't be able to handle it. The code on which the patch is based may be found in the "class-namespace" branch of https://pypi.python.org/pypi/cyordereddict.
components: Interpreter Core
nosy: eric.snow, ncoghlan
title: Make class definition namespace ordered by default
versions: Python 3.5
Added file: http://bugs.python.org/file39446/odict-class-definition-namespace.diff
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce