[Python-checkins] peps: Clarify the distinction between the definition ns and __dict__.
eric.snow
python-checkins at python.org
Sat Jun 11 22:26:33 EDT 2016
https://hg.python.org/peps/rev/b72a8581978c
changeset: 6368:b72a8581978c
user: Eric Snow <ericsnowcurrently at gmail.com>
date: Sat Jun 11 19:42:03 2016 -0600
summary:
Clarify the distinction between the definition ns and __dict__.
files:
pep-0520.txt | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/pep-0520.txt b/pep-0520.txt
--- a/pep-0520.txt
+++ b/pep-0520.txt
@@ -14,15 +14,19 @@
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
==========
--
Repository URL: https://hg.python.org/peps
More information about the Python-checkins
mailing list