[Zope3-checkins] CVS: Zope3/src/zodb/btrees - TreeSetTemplate.c:1.4 SetTemplate.c:1.4 BucketTemplate.c:1.17 BTreeTemplate.c:1.15 BTreeModuleTemplate.c:1.6

Jeremy Hylton jeremy@zope.com
Fri, 25 Apr 2003 15:03:05 -0400


Update of /cvs-repository/Zope3/src/zodb/btrees
In directory cvs.zope.org:/tmp/cvs-serv16613/src/zodb/btrees

Modified Files:
	TreeSetTemplate.c SetTemplate.c BucketTemplate.c 
	BTreeTemplate.c BTreeModuleTemplate.c 
Log Message:
Remove _p_serial from the PyPersist_HEAD.

Persistent objects still have an _p_serial attribute, but it is stored
in the instance dict for most objects.  If a specific class doesn't
have an instance dict, it must arrange to store _p_serial somewhere
else.  The BTrees store it in their object structs.

The change reduces the __basicsize__ of all persistent objects by 4
bytes, which saves 8 bytes in practice because of obmalloc rounding.

One consequence of this change is that objects don't have an _p_serial
== None at creation time.  Two tests depended on that.


=== Zope3/src/zodb/btrees/TreeSetTemplate.c 1.3 => 1.4 ===
--- Zope3/src/zodb/btrees/TreeSetTemplate.c:1.3	Fri Feb 21 12:33:01 2003
+++ Zope3/src/zodb/btrees/TreeSetTemplate.c	Fri Apr 25 15:02:34 2003
@@ -229,7 +229,7 @@
     (getiterfunc)BTree_getiter,		/* tp_iter */
     0,					/* tp_iternext */
     TreeSet_methods,			/* tp_methods */
-    0,					/* tp_members */
+    BTree_members,			/* tp_members */
     0,					/* tp_getset */
     0,					/* tp_base */
     0,					/* tp_dict */


=== Zope3/src/zodb/btrees/SetTemplate.c 1.3 => 1.4 ===
--- Zope3/src/zodb/btrees/SetTemplate.c:1.3	Fri Feb 21 12:33:01 2003
+++ Zope3/src/zodb/btrees/SetTemplate.c	Fri Apr 25 15:02:34 2003
@@ -320,7 +320,7 @@
     (getiterfunc)Bucket_getiter,	/* tp_iter */
     0,					/* tp_iternext */
     Set_methods,			/* tp_methods */
-    0,					/* tp_members */
+    Bucket_members,			/* tp_members */
     0,					/* tp_getset */
     0,					/* tp_base */
     0,					/* tp_dict */


=== Zope3/src/zodb/btrees/BucketTemplate.c 1.16 => 1.17 ===
--- Zope3/src/zodb/btrees/BucketTemplate.c:1.16	Wed Apr 16 11:59:04 2003
+++ Zope3/src/zodb/btrees/BucketTemplate.c	Fri Apr 25 15:02:34 2003
@@ -1421,6 +1421,7 @@
 */
 
 static struct PyMemberDef Bucket_members[] = {
+    {"_p_serial", T_OBJECT, offsetof(Bucket, po_serial)},
     {"_next", T_OBJECT, offsetof(Bucket, next)},
     {NULL}
 };
@@ -1508,7 +1509,6 @@
     Py_XDECREF(self->po_dm);
     Py_XDECREF(self->po_oid);
     Py_XDECREF(self->po_serial);
-    self->po_dm = NULL;
     if (self->po_state != GHOST)
 	_bucket_clear(self);
     PyObject_GC_Del(self);


=== Zope3/src/zodb/btrees/BTreeTemplate.c 1.14 => 1.15 ===
--- Zope3/src/zodb/btrees/BTreeTemplate.c:1.14	Fri Apr 11 11:55:32 2003
+++ Zope3/src/zodb/btrees/BTreeTemplate.c	Fri Apr 25 15:02:34 2003
@@ -1796,6 +1796,7 @@
 */
 
 static struct PyMemberDef BTree_members[] = {
+    {"_p_serial", T_OBJECT, offsetof(BTree, po_serial)},
     {"_firstbucket", T_OBJECT, offsetof(BTree, firstbucket), RO},
     {NULL}
 };
@@ -1904,7 +1905,6 @@
         PyObject_ClearWeakRefs((PyObject *)self);
     Py_XDECREF(self->po_dm);
     Py_XDECREF(self->po_oid);
-    Py_XDECREF(self->po_serial);
     self->po_dm = NULL;
     if (self->po_state != GHOST)
 	_BTree_clear(self);


=== Zope3/src/zodb/btrees/BTreeModuleTemplate.c 1.5 => 1.6 ===
--- Zope3/src/zodb/btrees/BTreeModuleTemplate.c:1.5	Mon Mar 31 11:37:04 2003
+++ Zope3/src/zodb/btrees/BTreeModuleTemplate.c	Fri Apr 25 15:02:34 2003
@@ -56,10 +56,7 @@
 
 static void PyVar_Assign(PyObject **v, PyObject *e) { Py_XDECREF(*v); *v=e;}
 #define ASSIGN(V,E) PyVar_Assign(&(V),(E))
-#define ASSIGNC(V,E) (Py_INCREF((E)), PyVar_Assign(&(V),(E)))
 #define UNLESS(E) if (!(E))
-#define UNLESS_ASSIGN(V,E) ASSIGN(V,E); UNLESS(V)
-#define LIST(O) ((PyListObject*)(O))
 #define OBJECT(O) ((PyObject*)(O))
 
 #define MIN_BUCKET_ALLOC 16
@@ -87,6 +84,7 @@
 #ifdef PERSISTENT
 #define sizedcontainer_HEAD         \
     PyPersist_HEAD                  \
+    PyObject *po_serial;            \
     PyObject *po_weaklist;          \
     int size;                       \
     int len;