[Python-checkins] cpython: Issue #19218: Rename collections.abc to _collections_abc in order to speed up

christian.heimes python-checkins at python.org
Sun Oct 13 02:27:33 CEST 2013


http://hg.python.org/cpython/rev/0b6052f2a8ee
changeset:   86273:0b6052f2a8ee
user:        Christian Heimes <christian at cheimes.de>
date:        Sun Oct 13 02:04:20 2013 +0200
summary:
  Issue #19218: Rename collections.abc to _collections_abc in order to speed up interpreter start

files:
  Doc/library/collections.abc.rst |  2 +-
  Lib/collections/abc.py          |  0 
  Lib/collections/__init__.py     |  6 +++---
  Lib/os.py                       |  2 +-
  Lib/random.py                   |  2 +-
  Lib/test/test_site.py           |  5 +++++
  Misc/NEWS                       |  3 +++
  7 files changed, 14 insertions(+), 6 deletions(-)


diff --git a/Doc/library/collections.abc.rst b/Doc/library/collections.abc.rst
--- a/Doc/library/collections.abc.rst
+++ b/Doc/library/collections.abc.rst
@@ -15,7 +15,7 @@
    import itertools
    __name__ = '<doctest>'
 
-**Source code:** :source:`Lib/collections/abc.py`
+**Source code:** :source:`Lib/_collections_abc.py`
 
 --------------
 
diff --git a/Lib/collections/abc.py b/Lib/_collections_abc.py
rename from Lib/collections/abc.py
rename to Lib/_collections_abc.py
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -3,9 +3,9 @@
 
 # For backwards compatibility, continue to make the collections ABCs
 # available through the collections module.
-from collections.abc import *
-import collections.abc
-__all__ += collections.abc.__all__
+from _collections_abc import *
+import _collections_abc
+__all__ += _collections_abc.__all__
 
 from _collections import deque, defaultdict
 from operator import itemgetter as _itemgetter, eq as _eq
diff --git a/Lib/os.py b/Lib/os.py
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -631,7 +631,7 @@
 
 
 # Change environ to automatically call putenv(), unsetenv if they exist.
-from collections.abc import MutableMapping
+from _collections_abc import MutableMapping
 
 class _Environ(MutableMapping):
     def __init__(self, data, encodekey, decodekey, encodevalue, decodevalue, putenv, unsetenv):
diff --git a/Lib/random.py b/Lib/random.py
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -41,7 +41,7 @@
 from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
 from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin
 from os import urandom as _urandom
-from collections.abc import Set as _Set, Sequence as _Sequence
+from _collections_abc import Set as _Set, Sequence as _Sequence
 from hashlib import sha512 as _sha512
 
 __all__ = ["Random","seed","random","uniform","randint","choice","sample",
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -445,6 +445,11 @@
         self.assertNotIn('locale', modules, stderr)
         # http://bugs.python.org/issue19209
         self.assertNotIn('copyreg', modules, stderr)
+        # http://bugs.python.org/issue19218>
+        collection_mods = {'_collections', 'collections', 'functools',
+                           'heapq', 'itertools', 'keyword', 'operator',
+                           'reprlib', 'types', 'weakref'}
+        self.assertFalse(modules.intersection(re_mods), stderr)
 
 
 if __name__ == "__main__":
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -42,6 +42,9 @@
 Library
 -------
 
+- Issue #19218: Rename collections.abc to _collections_abc in order to
+  speed up interpreter start.
+
 - Issue #18582: Add 'pbkdf2_hmac' to the hashlib module. It implements PKCS#5
   password-based key derivation functions with HMAC as pseudorandom function.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list