SVN: ZODB/trunk/src/ZODB/broken.py Added a small optimization to avoid unnecessary imports that were

Jim Fulton <[email protected]>
Newsgroups gmane.comp.python.zope.zodb.cvs
Message-ID <[email protected]>
Log message for revision 112414:
  Added a small optimization to avoid unnecessary imports that were
  sucking up a lot of time, as shown in some profile output.
  

Changed:
  U   ZODB/trunk/src/ZODB/broken.py

-=-
Modified: ZODB/trunk/src/ZODB/broken.py
===================================================================
--- ZODB/trunk/src/ZODB/broken.py	2010-05-17 13:36:20 UTC (rev 112413)
+++ ZODB/trunk/src/ZODB/broken.py	2010-05-17 15:01:51 UTC (rev 112414)
@@ -183,7 +183,14 @@
 
          >>> broken_cache.clear()
        """
+
+    # short circuit common case:
     try:
+        return getattr(sys.modules[modulename], globalname)
+    except (AttributeError, KeyError):
+        pass
+
+    try:
         __import__(modulename)
     except ImportError:
         pass
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.