Clarify the distinction between the definition ns and __dict__.

This commit is contained in:
Eric Snow 2016-06-11 19:42:03 -06:00
parent 97e820b228
commit 4f37f47475
1 changed files with 7 additions and 3 deletions

View File

@ -14,15 +14,19 @@ Post-History: 7-Jun-2016
Abstract
========
When a class is defined using a ``class`` statement, the class body is
executed within a namespace. After the execution completes, that
namespace is copied into new ``dict`` and the original definition
namespace is discarded. The new copy is stored away as the class's
namespace and is exposed as ``__dict__`` through a read-only proxy.
This PEP changes the default class definition namespace to ``OrderedDict``.
The long-lived class namespace (``__dict__``) will remain a ``dict``.
Furthermore, the order in which the attributes are defined in each class
body will now be preserved in the ``__definition_order__`` attribute of
the class. This allows introspection of the original definition order,
e.g. by class decorators.
Note: just to be clear, this PEP is *not* about changing ``__dict__`` for
classes to ``OrderedDict``.
Motivation
==========