SVN: ZODB/trunk/src/persistent/cPersistence.c Minor optimization in __getstate__ to avoid a needless dict allocation

Jim Fulton <[email protected]>
Newsgroups gmane.comp.python.zope.zodb.cvs
Message-ID <[email protected]>
Log message for revision 103109:
  Minor optimization in __getstate__ to avoid a needless dict allocation
  for objects that don't use slots, which are the vast majority of
  persistent objects.
  

Changed:
  U   ZODB/trunk/src/persistent/cPersistence.c

-=-
Modified: ZODB/trunk/src/persistent/cPersistence.c
===================================================================
--- ZODB/trunk/src/persistent/cPersistence.c	2009-08-23 14:34:05 UTC (rev 103108)
+++ ZODB/trunk/src/persistent/cPersistence.c	2009-08-23 15:29:26 UTC (rev 103109)
@@ -280,6 +280,12 @@
   slotnames = PyDict_GetItem(cls->tp_dict, py___slotnames__);
   if (slotnames)
     {
+      int n = PyObject_Not(slotnames);
+      if (n < 0)
+        return NULL;
+      if (n)
+        slotnames = Py_None;
+      
       Py_INCREF(slotnames);
       return slotnames;
     }
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.