[Zodb-checkins] CVS: StandaloneZODB/BTrees - BTreeModuleTemplate.c:1.19 BTreeTemplate.c:1.22 BucketTemplate.c:1.26 IIBTree.py:1.5 IOBTree.py:1.5 OIBTree.py:1.5 OOBTree.py:1.5 SetOpTemplate.c:1.11 SetTemplate.c:1.14 TreeSetTemplate.c:1.12 _IIBTree.c:1.4 _IOBTree.c:1.4 __init__.py:1.4

Jeremy Hylton jeremy@zope.com
Wed, 20 Feb 2002 18:59:52 -0500


Update of /cvs-repository/StandaloneZODB/BTrees
In directory cvs.zope.org:/tmp/cvs-serv23312/Persistence/BTrees

Modified Files:
	BTreeModuleTemplate.c BTreeTemplate.c BucketTemplate.c 
	IIBTree.py IOBTree.py OIBTree.py OOBTree.py SetOpTemplate.c 
	SetTemplate.c TreeSetTemplate.c _IIBTree.c _IOBTree.c 
	__init__.py 
Log Message:
Initial cut at BTrees implementation.  It compiles, but does not work.



=== StandaloneZODB/BTrees/BTreeModuleTemplate.c 1.18 => 1.19 ===
  ****************************************************************************/
 
+#include "Python.h"
 #ifdef PERSISTENT
 #include "cPersistence.h"
+#include "cPersistenceAPI.h"
 
-/***************************************************************
-   The following are macros that ought to be in cPersistence.h */
-#ifndef PER_USE 
-
-#define PER_USE(O) \
-(((O)->state != cPersistent_GHOST_STATE \
-  || (cPersistenceCAPI->setstate((PyObject*)(O)) >= 0)) \
- ? (((O)->state==cPersistent_UPTODATE_STATE) \
-    ? ((O)->state=cPersistent_STICKY_STATE) : 1) : 0)
-
-#define PER_ACCESSED(O) ((O)->atime=((long)(time(NULL)/3))%65536) 
-
-
-#endif
 /***************************************************************/
 
 #else
@@ -70,7 +58,7 @@
 
 typedef struct Bucket_s {
 #ifdef PERSISTENT
-  cPersistent_HEAD
+  PyPersist_HEAD
 #else
   PyObject_HEAD
 #endif
@@ -88,7 +76,7 @@
 
 typedef struct {
 #ifdef PERSISTENT
-  cPersistent_HEAD
+  PyPersist_HEAD
 #else
   PyObject_HEAD
 #endif
@@ -97,7 +85,7 @@
   BTreeItem *data;
 } BTree;
 
-staticforward PyExtensionClass BTreeType;
+staticforward PyTypeObject BTreeType;
 
 
 #define BTREE(O) ((BTree*)(O))
@@ -282,44 +270,37 @@
 BTREEITEMSTEMPLATE_C
 ;
 
+int
+init_persist_type(PyTypeObject *type)
+{
+    type->ob_type = &PyType_Type;
+    type->tp_getattro = PyPersist_TYPE->tp_getattro;
+    type->tp_setattro = PyPersist_TYPE->tp_setattro;
+
+    /* XXX for now */
+    type->tp_traverse = PyPersist_TYPE->tp_traverse;
+    type->tp_clear = PyPersist_TYPE->tp_clear;
+
+    return PyType_Ready(type);
+}
+
 void 
 INITMODULE (void)
 {
   PyObject *m, *d, *c;
 
-  UNLESS (sort_str=PyString_FromString("sort")) return;
-  UNLESS (reverse_str=PyString_FromString("reverse")) return;
-  UNLESS (items_str=PyString_FromString("items")) return;
-  UNLESS (__setstate___str=PyString_FromString("__setstate__")) return;
-
-  UNLESS (PyExtensionClassCAPI=PyCObject_Import("ExtensionClass","CAPI"))
+  sort_str = PyString_InternFromString("sort");
+  if (!sort_str)
+      return;
+  reverse_str = PyString_InternFromString("reverse");
+  if (!reverse_str)
+      return;
+  __setstate___str = PyString_InternFromString("__setstate__");
+  if (!__setstate___str)
       return;
-
-#ifdef PERSISTENT
-  if ((cPersistenceCAPI=PyCObject_Import("cPersistence","CAPI")))
-    {
-	BucketType.methods.link=cPersistenceCAPI->methods;
-	BucketType.tp_getattro=cPersistenceCAPI->getattro;
-	BucketType.tp_setattro=cPersistenceCAPI->setattro;
-
-	SetType.methods.link=cPersistenceCAPI->methods;
-	SetType.tp_getattro=cPersistenceCAPI->getattro;
-	SetType.tp_setattro=cPersistenceCAPI->setattro;
-
-	BTreeType.methods.link=cPersistenceCAPI->methods;
-	BTreeType.tp_getattro=cPersistenceCAPI->getattro;
-	BTreeType.tp_setattro=cPersistenceCAPI->setattro;
-
-	TreeSetType.methods.link=cPersistenceCAPI->methods;
-	TreeSetType.tp_getattro=cPersistenceCAPI->getattro;
-	TreeSetType.tp_setattro=cPersistenceCAPI->setattro;
-    }
-  else return;
 
   /* Grab the ConflictError class */
-
   m = PyImport_ImportModule("ZODB.POSException");
-
   if (m != NULL) {
   	c = PyObject_GetAttrString(m, "BTreesConflictError");
   	if (c != NULL) 
@@ -332,31 +313,40 @@
 	ConflictError=PyExc_ValueError;
   }
 
-#else
-  BTreeType.tp_getattro=PyExtensionClassCAPI->getattro;
-  BucketType.tp_getattro=PyExtensionClassCAPI->getattro;
-  SetType.tp_getattro=PyExtensionClassCAPI->getattro;
-  TreeSetType.tp_getattro=PyExtensionClassCAPI->getattro;
-#endif
-
-  BTreeItemsType.ob_type=&PyType_Type;
-
 #ifdef INTSET_H
   UNLESS(d = PyImport_ImportModule("intSet")) return;
   UNLESS(intSetType = PyObject_GetAttrString (d, "intSet")) return;
   Py_DECREF (d); 
 #endif
 
+  /* Initialize the PyPersist_C_API and the type objects. */
+  PyPersist_C_API = PyCObject_Import("Persistence.cPersistence", "C_API");
+  if (PyPersist_C_API == NULL)
+      return;
+
+  BTreeItemsType.ob_type = &PyType_Type;
+  init_persist_type(&BucketType);
+  init_persist_type(&BTreeType);
+  init_persist_type(&SetType);
+  init_persist_type(&TreeSetType);
+
   /* Create the module and add the functions */
-  m = Py_InitModule4("_" MOD_NAME_PREFIX "BTree", module_methods,
-		     BTree_module_documentation,
-		     (PyObject*)NULL,PYTHON_API_VERSION);
+  m = Py_InitModule4("_" MOD_NAME_PREFIX "BTree", 
+		     module_methods, BTree_module_documentation,
+		     (PyObject *)NULL, PYTHON_API_VERSION);
 
   /* Add some symbolic constants to the module */
   d = PyModule_GetDict(m);
-
-  PyExtensionClass_Export(d,MOD_NAME_PREFIX "Bucket", BucketType);
-  PyExtensionClass_Export(d,MOD_NAME_PREFIX "BTree", BTreeType);
-  PyExtensionClass_Export(d,MOD_NAME_PREFIX "Set", SetType);
-  PyExtensionClass_Export(d,MOD_NAME_PREFIX "TreeSet", TreeSetType);
+  if (PyDict_SetItemString(d, MOD_NAME_PREFIX "Bucket", 
+			   (PyObject *)&BucketType) < 0)
+      return;
+  if (PyDict_SetItemString(d, MOD_NAME_PREFIX "BTree", 
+			   (PyObject *)&BTreeType) < 0)
+      return;
+  if (PyDict_SetItemString(d, MOD_NAME_PREFIX "Set", 
+			   (PyObject *)&SetType) < 0)
+      return;
+  if (PyDict_SetItemString(d, MOD_NAME_PREFIX "TreeSet", 
+			   (PyObject *)&TreeSetType) < 0)
+      return;
 }


=== StandaloneZODB/BTrees/BTreeTemplate.c 1.21 => 1.22 ===
           && self->len == 1                            /* We have only one   */
           && ! SameType_Check(self, self->data->value) /* It's our child     */
-          && BUCKET(self->data->value)->oid == NULL    /* It's in our record */
+          && BUCKET(self->data->value)->po_oid == NULL /* It's in our record */
           )
       ) 
     if (PER_CHANGED(self) < 0) 
@@ -570,10 +570,10 @@
 static PyObject *
 BTree__p_deactivate(BTree *self, PyObject *args)
 {
-  if (self->state==cPersistent_UPTODATE_STATE && self->jar)
+  if (self->po_state == UPTODATE && self->po_dm)
     {
       if (_BTree_clear(self) < 0) return NULL;
-      self->state=cPersistent_GHOST_STATE;
+      self->po_state = GHOST;
     }
 
   Py_INCREF(Py_None);
@@ -619,7 +619,7 @@
       if (self->len == 1 
           && self->data->value->ob_type != self->ob_type
 #ifdef PERSISTENT
-          && BUCKET(self->data->value)->oid == NULL
+          && BUCKET(self->data->value)->po_oid == NULL
 #endif
           )
         {
@@ -731,9 +731,9 @@
         {
           if (! firstbucket) firstbucket=self->data->value;
 
-          UNLESS (ExtensionClassSubclassInstance_Check(
-                    firstbucket, 
-                    noval ? &SetType : &BucketType))
+	  /* XXX what is this? */
+	  if (!PyObject_IsInstance(firstbucket, (PyObject *)
+				   (noval ? &SetType : &BucketType)))
             {
               PyErr_SetString(PyExc_TypeError, 
                               "No firstbucket in non-empty BTree");
@@ -788,7 +788,7 @@
     UNLESS (s[i]==Py_None || PyTuple_Check(s[i]))
       return merge_error(-100, -100, -100, -100);
 
-  if (ExtensionClassSubclassInstance_Check(self, &BTreeType))
+  if (PyObject_IsInstance((PyObject *)self, (PyObject *)&BTreeType))
       r = _bucket__p_resolveConflict(OBJECT(&BucketType), s);
   else
       r = _bucket__p_resolveConflict(OBJECT(&SetType), s);
@@ -1238,11 +1238,7 @@
 BTree_dealloc(BTree *self)
 {
   _BTree_clear(self);
-
-  PER_DEL(self);
-
-  Py_DECREF(self->ob_type);
-  PyMem_DEL(self);
+  PyPersist_TYPE->tp_dealloc((PyObject *)self);
 }
 
 static int
@@ -1301,35 +1297,46 @@
   0,0,0,0,0,0,0,0,0,0,
   (inquiry)BTree_nonzero};
 
-static PyExtensionClass BTreeType = {
-  PyObject_HEAD_INIT(NULL)
-  0,				/*ob_size*/
-  MOD_NAME_PREFIX "BTree",			/*tp_name*/
-  sizeof(BTree),		/*tp_basicsize*/
-  0,				/*tp_itemsize*/
-  /************* methods ********************/
-  (destructor) BTree_dealloc,/*tp_dealloc*/
-  (printfunc)0,			/*tp_print*/
-  (getattrfunc)0,		/*obsolete tp_getattr*/
-  (setattrfunc)0,		/*obsolete tp_setattr*/
-  (cmpfunc)0,			/*tp_compare*/
-  (reprfunc)0,			/*tp_repr*/
-  &BTree_as_number_for_nonzero,	/*tp_as_number*/
-  0,				/*tp_as_sequence*/
-  &BTree_as_mapping,	/*tp_as_mapping*/
-  (hashfunc)0,			/*tp_hash*/
-  (ternaryfunc)0,		/*tp_call*/
-  (reprfunc)0,			/*tp_str*/
-  (getattrofunc)0,
-  0,				/*tp_setattro*/
-  
-  /* Space for future expansion */
-  0L,0L,
-  "Mapping type implemented as sorted list of items", 
-  METHOD_CHAIN(BTree_methods),
-  EXTENSIONCLASS_BASICNEW_FLAG 
-#ifdef PERSISTENT
-  | PERSISTENT_TYPE_FLAG 
-#endif
-  | EXTENSIONCLASS_NOINSTDICT_FLAG,
+static PyTypeObject BTreeType = {
+    PyObject_HEAD_INIT(NULL) /* PyPersist_Type */
+    0,					/* ob_size */
+    "Persistence.BTrees.OOBTree." MOD_NAME_PREFIX "BTree",		/* tp_name */
+    sizeof(BTree),			/* tp_basicsize */
+    0,					/* tp_itemsize */
+    (destructor)BTree_dealloc,		/* tp_dealloc */
+    0,					/* tp_print */
+    0,					/* tp_getattr */
+    0,					/* tp_setattr */
+    0,					/* tp_compare */
+    0,					/* tp_repr */
+    &BTree_as_number_for_nonzero,	/* tp_as_number */
+    0,					/* tp_as_sequence */
+    &BTree_as_mapping,			/* tp_as_mapping */
+    0,					/* tp_hash */
+    0,					/* tp_call */
+    0,					/* tp_str */
+    0,					/* tp_getattro */
+    0,					/* tp_setattro */
+    0,					/* tp_as_buffer */
+/* XXX need to define traverse and clear functions */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
+	    Py_TPFLAGS_BASETYPE, 	/* tp_flags */
+    0,					/* tp_doc */
+    0,	/* tp_traverse */
+    0,		/* tp_clear */
+    0,					/* tp_richcompare */
+    0,					/* tp_weaklistoffset */
+    0,					/* tp_iter */
+    0,					/* tp_iternext */
+    BTree_methods,			/* tp_methods */
+    0,					/* tp_members */
+    0,					/* tp_getset */
+    0,					/* tp_base */
+    0,					/* tp_dict */
+    0,					/* tp_descr_get */
+    0,					/* tp_descr_set */
+    0,					/* tp_dictoffset */
+    0,					/* tp_init */
+    0,					/* tp_alloc */
+    PyType_GenericNew,			/* tp_new */
 };


=== StandaloneZODB/BTrees/BucketTemplate.c 1.25 => 1.26 ===
 bucket__p_deactivate(Bucket *self, PyObject *args)
 {
-  if (self->state==cPersistent_UPTODATE_STATE && self->jar)
+  if (self->po_state == UPTODATE && self->po_dm)
     {
       if (_bucket_clear(self) < 0) return NULL;
-      self->state=cPersistent_GHOST_STATE;
+      self->po_state = GHOST;
     }
 
   Py_INCREF(Py_None);
@@ -1130,14 +1130,10 @@
 };
 
 static void
-Bucket_dealloc(Bucket *self)
+bucket_dealloc(Bucket *self)
 {
   _bucket_clear(self);
-
-  PER_DEL(self);
-
-  Py_DECREF(self->ob_type);
-  PyMem_DEL(self);
+  PyPersist_TYPE->tp_dealloc((PyObject *)self);
 }
 
 /* Code to access Bucket objects as mappings */
@@ -1164,8 +1160,11 @@
   static PyObject *format;
   PyObject *r, *t;
 
-  UNLESS (format) UNLESS (format=PyString_FromString(MOD_NAME_PREFIX "Bucket(%s)")) 
-    return NULL;
+  if (format == NULL) {
+      format = PyString_FromString(MOD_NAME_PREFIX "Bucket(%s)");
+      if (format == NULL)
+	  return NULL;
+  }
   UNLESS (t=PyTuple_New(1)) return NULL;
   UNLESS (r=bucket_items(self,NULL)) goto err;
   PyTuple_SET_ITEM(t,0,r);
@@ -1177,39 +1176,49 @@
   return NULL;
 }
 
-static PyExtensionClass BucketType = {
-  PyObject_HEAD_INIT(NULL)
-  0,				/*ob_size*/
-  MOD_NAME_PREFIX "Bucket",			/*tp_name*/
-  sizeof(Bucket),		/*tp_basicsize*/
-  0,				/*tp_itemsize*/
-  /*********** methods ***********************/
-  (destructor) Bucket_dealloc,	/*tp_dealloc*/
-  (printfunc)0,			/*tp_print*/
-  (getattrfunc)0,		/*obsolete tp_getattr*/
-  (setattrfunc)0,		/*obsolete tp_setattr*/
-  (cmpfunc)0,			/*tp_compare*/
-  (reprfunc) bucket_repr,	/*tp_repr*/
-  0,				/*tp_as_number*/
-  0,				/*tp_as_sequence*/
-  &Bucket_as_mapping,		/*tp_as_mapping*/
-  (hashfunc)0,			/*tp_hash*/
-  (ternaryfunc)0,		/*tp_call*/
-  (reprfunc)0,			/*tp_str*/
-  (getattrofunc)0,		/*tp_getattro*/
-  0,				/*tp_setattro*/
-  
-  /* Space for future expansion */
-  0L,0L,
-  "Mapping type implemented as sorted list of items", 
-  METHOD_CHAIN(Bucket_methods),
-  EXTENSIONCLASS_BASICNEW_FLAG
-#ifdef PERSISTENT
-  | PERSISTENT_TYPE_FLAG 
-#endif
-  | EXTENSIONCLASS_NOINSTDICT_FLAG,
+static PyTypeObject BucketType = {
+    PyObject_HEAD_INIT(NULL) /* PyPersist_Type */
+    0,					/* ob_size */
+    MOD_NAME_PREFIX "Bucket",		/* tp_name */
+    sizeof(Bucket),			/* tp_basicsize */
+    0,					/* tp_itemsize */
+    (destructor)bucket_dealloc,		/* tp_dealloc */
+    0,					/* tp_print */
+    0,					/* tp_getattr */
+    0,					/* tp_setattr */
+    0,					/* tp_compare */
+    (reprfunc)bucket_repr,		/* tp_repr */
+    0,					/* tp_as_number */
+    0,					/* tp_as_sequence */
+    &Bucket_as_mapping,			/* tp_as_mapping */
+    0,					/* tp_hash */
+    0,					/* tp_call */
+    0,					/* tp_str */
+    0,					/* tp_getattro */
+    0,					/* tp_setattro */
+    0,					/* tp_as_buffer */
+/* XXX need to define traverse and clear functions */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
+	    Py_TPFLAGS_BASETYPE, 	/* tp_flags */
+    0,					/* tp_doc */
+    0,	/* tp_traverse */
+    0,		/* tp_clear */
+    0,					/* tp_richcompare */
+    0,					/* tp_weaklistoffset */
+    0,					/* tp_iter */
+    0,					/* tp_iternext */
+    Bucket_methods,			/* tp_methods */
+    0,					/* tp_members */
+    0,					/* tp_getset */
+    0,					/* tp_base */
+    0,					/* tp_dict */
+    0,					/* tp_descr_get */
+    0,					/* tp_descr_set */
+    0,					/* tp_dictoffset */
+    0,					/* tp_init */
+    0,					/* tp_alloc */
+    PyType_GenericNew,			/* tp_new */
 };
-
 
 static int 
 nextBucket(SetIteration *i)


=== StandaloneZODB/BTrees/IIBTree.py 1.4 => 1.5 ===
 # We don't really want _ names in pickles, so update all of the __module__
 # references.
-for o in globals().values():
-    if hasattr(o, '__module__'):
-        o.__module__=__name__
+##for o in globals().values():
+##    if hasattr(o, '__module__'):
+##        o.__module__=__name__


=== StandaloneZODB/BTrees/IOBTree.py 1.4 => 1.5 ===
 # We don't really want _ names in pickles, so update all of the __module__
 # references.
-for o in globals().values():
-    if hasattr(o, '__module__'):
-        o.__module__=__name__
+##for o in globals().values():
+##    if hasattr(o, '__module__'):
+##        o.__module__=__name__


=== StandaloneZODB/BTrees/OIBTree.py 1.4 => 1.5 ===
 # We don't really want _ names in pickles, so update all of the __module__
 # references.
-for o in globals().values():
-    if hasattr(o, '__module__'):
-        o.__module__=__name__
+##for o in globals().values():
+##    if hasattr(o, '__module__'):
+##        o.__module__=__name__


=== StandaloneZODB/BTrees/OOBTree.py 1.4 => 1.5 ===
 # We don't really want _ names in pickles, so update all of the __module__
 # references.
-for o in globals().values():
-    if hasattr(o, '__module__'):
-        o.__module__=__name__
+##for o in globals().values():
+##    print o
+##    if hasattr(o, '__module__'):
+##        o.__module__=__name__
+
+# XXX can't figure out why _reduce() won't call our __getstate__.
+
+import copy_reg
+
+def pickle_OOBTree(t):
+    return t.__class__, t.__getstate__()
+
+def unpickle_OOBTree(state):
+    obj = OOBTree.__new__(OOBTree, None)
+    obj.__setstate__(state)
+    return obj
+
+copy_reg.pickle(OOBTree, pickle_OOBTree)


=== StandaloneZODB/BTrees/SetOpTemplate.c 1.10 => 1.11 ===
   i->position=0;
 
-  if (ExtensionClassSubclassInstance_Check(s, &BucketType))
+  if (PyObject_IsInstance(s, (PyObject *)&BucketType))
     {
       i->set = s;
       Py_INCREF(s);
@@ -82,7 +82,7 @@
 
       i->hasValue=1;
     }
-  else if (ExtensionClassSubclassInstance_Check(s, &SetType))
+  else if (PyObject_IsInstance(s, (PyObject *)&SetType))
     {
       i->set = s;
       Py_INCREF(s);
@@ -90,7 +90,7 @@
       i->next=nextSet;
       i->hasValue=0;
     }
-  else if (ExtensionClassSubclassInstance_Check(s, &BTreeType))
+  else if (PyObject_IsInstance(s, (PyObject *)&BTreeType))
     {
       i->set=BTree_rangeSearch(BTREE(s), NULL, 'i');
       UNLESS(i->set) return -1;
@@ -104,7 +104,7 @@
         i->next=nextTreeSetItems;
       i->hasValue=1;
     }
-  else if (ExtensionClassSubclassInstance_Check(s, &TreeSetType))
+  else if (PyObject_IsInstance(s, (PyObject *)&TreeSetType))
     {
       i->set=BTree_rangeSearch(BTREE(s), NULL, 'k');
       UNLESS(i->set) return -1;


=== StandaloneZODB/BTrees/SetTemplate.c 1.13 => 1.14 ===
 };
 
-static PyExtensionClass SetType = {
-  PyObject_HEAD_INIT(NULL)
-  0,				/*ob_size*/
-  MOD_NAME_PREFIX "Set",			/*tp_name*/
-  sizeof(Bucket),		/*tp_basicsize*/
-  0,				/*tp_itemsize*/
-  /*********** methods ***********************/
-  (destructor) Bucket_dealloc,	/*tp_dealloc*/
-  (printfunc)0,			/*tp_print*/
-  (getattrfunc)0,		/*obsolete tp_getattr*/
-  (setattrfunc)0,		/*obsolete tp_setattr*/
-  (cmpfunc)0,			/*tp_compare*/
-  (reprfunc) set_repr,		/*tp_repr*/
-  0,				/*tp_as_number*/
-  &set_as_sequence,		/*tp_as_sequence*/
-  0,		                /*tp_as_mapping*/
-  (hashfunc)0,			/*tp_hash*/
-  (ternaryfunc)0,		/*tp_call*/
-  (reprfunc)0,			/*tp_str*/
-  (getattrofunc)0,		/*tp_getattro*/
-  0,				/*tp_setattro*/
-  
-  /* Space for future expansion */
-  0L,0L,
-  "Set implemented as sorted keys", 
-  METHOD_CHAIN(Set_methods),
-  EXTENSIONCLASS_BASICNEW_FLAG 
-#ifdef PERSISTENT
-  | PERSISTENT_TYPE_FLAG 
-#endif
-  | EXTENSIONCLASS_NOINSTDICT_FLAG,
+static PyTypeObject SetType = {
+    PyObject_HEAD_INIT(NULL) /* PyPersist_Type */
+    0,					/* ob_size */
+    MOD_NAME_PREFIX "Set",		/* tp_name */
+    sizeof(Bucket),			/* tp_basicsize */
+    0,					/* tp_itemsize */
+    (destructor)bucket_dealloc,		/* tp_dealloc */
+    0,					/* tp_print */
+    0,					/* tp_getattr */
+    0,					/* tp_setattr */
+    0,					/* tp_compare */
+    (reprfunc)set_repr,			/* tp_repr */
+    0,					/* tp_as_number */
+    &set_as_sequence,			/* tp_as_sequence */
+    0,					/* tp_as_mapping */
+    0,					/* tp_hash */
+    0,					/* tp_call */
+    0,					/* tp_str */
+    0,					/* tp_getattro */
+    0,					/* tp_setattro */
+    0,					/* tp_as_buffer */
+/* XXX need to define traverse and clear functions */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
+	    Py_TPFLAGS_BASETYPE, 	/* tp_flags */
+    0,					/* tp_doc */
+    0,	/* tp_traverse */
+    0,		/* tp_clear */
+    0,					/* tp_richcompare */
+    0,					/* tp_weaklistoffset */
+    0,					/* tp_iter */
+    0,					/* tp_iternext */
+    Set_methods,			/* tp_methods */
+    0,					/* tp_members */
+    0,					/* tp_getset */
+    0,					/* tp_base */
+    0,					/* tp_dict */
+    0,					/* tp_descr_get */
+    0,					/* tp_descr_set */
+    0,					/* tp_dictoffset */
+    0,					/* tp_init */
+    0,					/* tp_alloc */
+    PyType_GenericNew,			/* tp_new */
 };
 
 static int 


=== StandaloneZODB/BTrees/TreeSetTemplate.c 1.11 => 1.12 ===
 };
 
-static PyExtensionClass TreeSetType = {
-  PyObject_HEAD_INIT(NULL)
-  0,				/*ob_size*/
-  MOD_NAME_PREFIX "TreeSet",		/*tp_name*/
-  sizeof(BTree),		/*tp_basicsize*/
-  0,				/*tp_itemsize*/
-  /************* methods ********************/
-  (destructor) BTree_dealloc,   /*tp_dealloc*/
-  (printfunc)0,			/*tp_print*/
-  (getattrfunc)0,		/*obsolete tp_getattr*/
-  (setattrfunc)0,		/*obsolete tp_setattr*/
-  (cmpfunc)0,			/*tp_compare*/
-  (reprfunc)0,			/*tp_repr*/
-  &BTree_as_number_for_nonzero,	/*tp_as_number*/
-  0,				/*tp_as_sequence*/
-  &TreeSet_as_mapping,		/*tp_as_mapping*/
-  (hashfunc)0,			/*tp_hash*/
-  (ternaryfunc)0,		/*tp_call*/
-  (reprfunc)0,			/*tp_str*/
-  (getattrofunc)0,
-  0,				/*tp_setattro*/
-  
-  /* Space for future expansion */
-  0L,0L,
-  "Set implemented as sorted tree of items", 
-  METHOD_CHAIN(TreeSet_methods),
-  EXTENSIONCLASS_BASICNEW_FLAG 
-#ifdef PERSISTENT
-  | PERSISTENT_TYPE_FLAG 
-#endif
-  | EXTENSIONCLASS_NOINSTDICT_FLAG,
+static PyTypeObject TreeSetType = {
+    PyObject_HEAD_INIT(NULL) /* PyPersist_Type */
+    0,					/* ob_size */
+    MOD_NAME_PREFIX "TreeSet",		/* tp_name */
+    sizeof(BTree),			/* tp_basicsize */
+    0,					/* tp_itemsize */
+    (destructor)BTree_dealloc,		/* tp_dealloc */
+    0,					/* tp_print */
+    0,					/* tp_getattr */
+    0,					/* tp_setattr */
+    0,					/* tp_compare */
+    0,					/* tp_repr */
+    &BTree_as_number_for_nonzero,	/* tp_as_number */
+    0,					/* tp_as_sequence */
+    &TreeSet_as_mapping,		/* tp_as_mapping */
+    0,					/* tp_hash */
+    0,					/* tp_call */
+    0,					/* tp_str */
+    0,					/* tp_getattro */
+    0,					/* tp_setattro */
+    0,					/* tp_as_buffer */
+/* XXX need to define traverse and clear functions */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
+	    Py_TPFLAGS_BASETYPE, 	/* tp_flags */
+    0,					/* tp_doc */
+    0,	/* tp_traverse */
+    0,		/* tp_clear */
+    0,					/* tp_richcompare */
+    0,					/* tp_weaklistoffset */
+    0,					/* tp_iter */
+    0,					/* tp_iternext */
+    TreeSet_methods,			/* tp_methods */
+    0,					/* tp_members */
+    0,					/* tp_getset */
+    0,					/* tp_base */
+    0,					/* tp_dict */
+    0,					/* tp_descr_get */
+    0,					/* tp_descr_set */
+    0,					/* tp_dictoffset */
+    0,					/* tp_init */
+    0,					/* tp_alloc */
+    PyType_GenericNew,			/* tp_new */
 };


=== StandaloneZODB/BTrees/_IIBTree.c 1.3 => 1.4 ===
 #include "intkeymacros.h"
 #include "intvaluemacros.h"
-#include "cPersistence.h"
 #ifndef EXCLUDE_INTSET_SUPPORT
 #include "BTree/intSet.h"
 #endif


=== StandaloneZODB/BTrees/_IOBTree.c 1.3 => 1.4 ===
 #include "intkeymacros.h"
 #include "objectvaluemacros.h"
-#include "cPersistence.h"
 #ifndef EXCLUDE_INTSET_SUPPORT
 #include "BTree/intSet.h"
 #endif


=== StandaloneZODB/BTrees/__init__.py 1.3 => 1.4 ===
+##import ZODB
 
-try: import intSet
-except: pass
-else: del intSet
+##try: import intSet
+##except: pass
+##else: del intSet
 
-# Register interfaces
-try: import Interface
-except ImportError: pass # Don't register interfaces if no scarecrow
-else:
-    import Interfaces
-    del Interfaces
-    del Interface
+### Register interfaces
+##try: import Interface
+##except ImportError: pass # Don't register interfaces if no scarecrow
+##else:
+##    import Interfaces
+##    del Interfaces
+##    del Interface