diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2012-09-06 05:19:38 (GMT) |
---|---|---|
committer | Eric Snow <ericsnowcurrently@gmail.com> | 2012-09-06 05:19:38 (GMT) |
commit | b2a61e1ead72a89d21a0bd84930dbb7a28be3793 (patch) | |
tree | a659ed9b5e439f1ec22b029bac405bd6180b35ad /Doc/whatsnew/3.3.rst | |
parent | 5b4faae30748c09930fa053442e1d6ff2823823c (diff) | |
download | cpython-b2a61e1ead72a89d21a0bd84930dbb7a28be3793.zip cpython-b2a61e1ead72a89d21a0bd84930dbb7a28be3793.tar.gz cpython-b2a61e1ead72a89d21a0bd84930dbb7a28be3793.tar.bz2 |
add whatsnew entry for PEP 421
Diffstat (limited to 'Doc/whatsnew/3.3.rst')
-rw-r--r-- | Doc/whatsnew/3.3.rst | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst index 47cbd4e..3891eb1 100644 --- a/Doc/whatsnew/3.3.rst +++ b/Doc/whatsnew/3.3.rst @@ -564,6 +564,41 @@ which considerably simplifies writing decorators and any code that validates or amends calling signatures or arguments. +PEP 421: Adding sys.implementation +================================== + +:pep:`421` - Adding sys.implementation + PEP written and implemented by Eric Snow. + +A new attribute on the :mod:`sys` module exposes details specific to the +implementation of the currently running interpreter. The initial set of +attributes on :attr:`sys.implementation` are ``name``, ``version``, +``hexversion``, and ``cache_tag``. + +The intention of ``sys.implementation`` is to consolidate into one namespace +the implementation-specific data used by the standard library. This allows +different Python implementations to share a single standard library code base +much more easily. In its initial state, ``sys.implementation`` holds only a +small portion of the implementation-specific data. Over time that ratio will +shift in order to make the standard library more portable. + +One example of improved standard library portability is ``cache_tag``. As of +Python 3.3, ``sys.implementation.cache_tag`` is used by :mod:`importlib` to +support :pep:`3147` compliance. Any Python implementation that uses +``importlib`` for its built-in import system may use ``cache_tag`` to control +the caching behavior for modules. + +SimpleNamespace +--------------- + +The implementation of ``sys.implementation`` also introduces a new type to +Python: :class:`types.SimpleNamespace`. In contrast to a mapping-based +namespace, like :class:`dict`, ``SimpleNamespace`` is attribute-based, like +:class:`object`. However, unlike ``object``, ``SimpleNamespace`` instances +are writable. This means that you can add, remove, and modify the namespace +through normal attribute access. + + .. _importlib: Using importlib as the Implementation of Import |