[pypy-svn] r14161 - pypy/branch/dist-2.4.1/lib-python/modified-2.4.1

ac at codespeak.net ac at codespeak.net
Sun Jul 3 18:29:00 CEST 2005


Author: ac
Date: Sun Jul  3 18:28:59 2005
New Revision: 14161

Added:
   pypy/branch/dist-2.4.1/lib-python/modified-2.4.1/copy.py
      - copied, changed from r14133, pypy/branch/dist-2.4.1/lib-python/2.4.1/copy.py
Log:
Make the copy module mych faster by not importing the inspect module.

Copied: pypy/branch/dist-2.4.1/lib-python/modified-2.4.1/copy.py (from r14133, pypy/branch/dist-2.4.1/lib-python/2.4.1/copy.py)
==============================================================================
--- pypy/branch/dist-2.4.1/lib-python/2.4.1/copy.py	(original)
+++ pypy/branch/dist-2.4.1/lib-python/modified-2.4.1/copy.py	Sun Jul  3 18:28:59 2005
@@ -62,9 +62,24 @@
 
 __all__ = ["Error", "copy", "deepcopy"]
 
-import inspect
 def _getspecial(cls, name):
-    for basecls in inspect.getmro(cls):
+    def getmro(cls):
+        def _searchbases(cls):
+            # Simulate the "classic class" search order.
+            if cls in result:
+                return
+            result.append(cls)
+            for base in cls.__bases__:
+                _searchbases(base)
+
+        if hasattr(cls, "__mro__"):
+            return cls.__mro__
+        else:
+            result = []
+            _searchbases(cls)
+            return result
+
+    for basecls in getmro(cls):
         try:
             return basecls.__dict__[name]
         except:



More information about the Pypy-commit mailing list