[Checkins] SVN: zope.app.keyreference/trunk/src/zope/app/keyreference/persistent.py Explain recent optimiziation to anybody reading this source code in the future.

Philipp von Weitershausen philikon at philikon.de
Fri Aug 15 01:29:17 EDT 2008


Log message for revision 89864:
  Explain recent optimiziation to anybody reading this source code in the future.
  

Changed:
  U   zope.app.keyreference/trunk/src/zope/app/keyreference/persistent.py

-=-
Modified: zope.app.keyreference/trunk/src/zope/app/keyreference/persistent.py
===================================================================
--- zope.app.keyreference/trunk/src/zope/app/keyreference/persistent.py	2008-08-15 05:23:28 UTC (rev 89863)
+++ zope.app.keyreference/trunk/src/zope/app/keyreference/persistent.py	2008-08-15 05:29:16 UTC (rev 89864)
@@ -61,8 +61,11 @@
 
     def __cmp__(self, other):
         if self.key_type_id == other.key_type_id:
+            # While it makes subclassing this class inconvenient,
+            # comparing the object's type is faster than doing an
+            # isinstance check.
             if type(self.object) is PersistentReference:
-                # we are doing conflict resolution.
+                # We are doing conflict resolution.
                 assert isinstance(other.object, PersistentReference), (
                     'other object claims to be '
                     'zope.app.keyreference.persistent but, during conflict '



More information about the Checkins mailing list