[Python-Dev] Preserving the definition order of class namespaces.
ncoghlan at gmail.com
Sun May 24 12:06:40 CEST 2015
On 24 May 2015 at 19:44, Mark Shannon <mark at hotpy.org> wrote:
> On 24/05/15 10:35, Nick Coghlan wrote:
>> If we leave __definition_order__ out for the time being then, for the
>> vast majority of code, the fact that the ephemeral namespace used to
>> evaluate the class body switched from being a basic dictionary to an
>> ordered one would be a hidden implementation detail, rather than
>> making all type objects a little bigger.
> and a little slower.
The runtime namespace used to store the class attributes is remaining
a plain dict object regardless, it's only the ephemeral one that's
used to evaluate the class body at definition time that Eric's
proposing to switch to an ordered dictionary.
That approach avoids any new runtime overhead when using the defined
class, while still making the order of attribute assignment available
to custom metaclasses by default.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev