[Checkins] SVN: zc.async/trunk/src/zc/async/ Optimize for performance.
Zvezdan Petkovic
zvezdan at zope.com
Mon Oct 13 15:39:44 EDT 2008
Log message for revision 92154:
Optimize for performance.
Changed:
U zc.async/trunk/src/zc/async/monitor.py
U zc.async/trunk/src/zc/async/utils.py
-=-
Modified: zc.async/trunk/src/zc/async/monitor.py
===================================================================
--- zc.async/trunk/src/zc/async/monitor.py 2008-10-13 19:34:48 UTC (rev 92153)
+++ zc.async/trunk/src/zc/async/monitor.py 2008-10-13 19:39:44 UTC (rev 92154)
@@ -56,7 +56,10 @@
elif getattr(obj, 'next', _marker) is not _marker:
# iterator. Duck typing too fuzzy, practically?
return tuple(obj)
+ # isinstance and providedBy are *not* redundant
+ # it's a performance optimization
elif ((types.FunctionType, types.BuiltinFunctionType) or
+ isinstance(obj, persistent.Persistent) or
persistent.interfaces.IPersistent.providedBy(obj)):
return zc.async.utils.custom_repr(obj)
return simplejson.JSONEncoder.default(self, obj)
Modified: zc.async/trunk/src/zc/async/utils.py
===================================================================
--- zc.async/trunk/src/zc/async/utils.py 2008-10-13 19:34:48 UTC (rev 92153)
+++ zc.async/trunk/src/zc/async/utils.py 2008-10-13 19:39:44 UTC (rev 92154)
@@ -334,7 +334,10 @@
return res
def custom_repr(obj):
- if persistent.interfaces.IPersistent.providedBy(obj):
+ # isinstance and providedBy are *not* redundant
+ # it's a performance optimization
+ if (isinstance(obj, persistent.Persistent) or
+ persistent.interfaces.IPersistent.providedBy(obj)):
dbname = "?"
if obj._p_jar is not None:
dbname = getattr(obj._p_jar.db(), 'database_name', "?")
More information about the Checkins
mailing list