[Zodb-checkins] SVN: ZODB/trunk/src/ZODB/broken.py Added a small optimization to avoid unnecessary imports that were
Jim Fulton
jim at zope.com
Mon May 17 11:01:52 EDT 2010
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
More information about the Zodb-checkins
mailing list