[Patches] PyMem [6/8] - Objects/*

Vladimir Marangozov Vladimir.Marangozov@inrialpes.fr
Sun, 30 Apr 2000 21:44:28 +0200 (CEST)


[ Objects/* ]

Major interventions w.r.t the new interfaces.

All builtin objects use the macro versions of the Object memory API.

Object constructors that inline PyObject_New/NewVar have been marked
as such. Object initializations with _Py_NewReference and the like
have been hidden (at best) with PyObject_INIT/INIT_VAR.

The functions for all memory APIs are implemented in object.c

--
       Vladimir MARANGOZOV          | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252

--

Disclaimer:

I confirm that, to the best of my knowledge and belief, this contribution is
free of any claims of third parties under copyright, patent or other rights
or interests ("claims").  To the extent that I have any such claims, I
hereby grant to CNRI a nonexclusive, irrevocable, royalty-free, worldwide
license to reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part of the
Python software and its related documentation, or any derivative versions
thereof, at no cost to CNRI or its licensed users, and to authorize others
to do so.

I acknowledge that CNRI may, at its sole discretion, decide whether or not
to incorporate this contribution in the Python software and its related
documentation.  I further grant CNRI permission to use my name and other
identifying information provided to CNRI by me for use in connection with
the Python software and its related documentation.

-------------------------------[ cut here ]---------------------------
diff -cr PyCVS/Objects/bufferobject.c PyMem/Objects/bufferobject.c
*** PyCVS/Objects/bufferobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/bufferobject.c	Sat Apr 29 23:28:21 2000
***************
*** 188,198 ****
  				"size must be zero or positive");
  		return NULL;
  	}
! 	b = (PyBufferObject *)malloc(sizeof(*b) + size);
  	if ( b == NULL )
  		return PyErr_NoMemory();
! 	b->ob_type = &PyBuffer_Type;
! 	_Py_NewReference((PyObject *)b);
  
  	b->b_base = NULL;
  	b->b_ptr = (void *)(b + 1);
--- 188,198 ----
  				"size must be zero or positive");
  		return NULL;
  	}
! 	/* PyObject_New is inlined */
! 	b = (PyBufferObject *) PyObject_MALLOC(sizeof(*b) + size);
  	if ( b == NULL )
  		return PyErr_NoMemory();
! 	PyObject_INIT((PyObject *)b, &PyBuffer_Type);
  
  	b->b_base = NULL;
  	b->b_ptr = (void *)(b + 1);
***************
*** 212,218 ****
  	PyBufferObject *self;
  {
  	Py_XDECREF(self->b_base);
! 	free((void *)self);
  }
  
  static int
--- 212,218 ----
  	PyBufferObject *self;
  {
  	Py_XDECREF(self->b_base);
! 	PyObject_DEL(self);
  }
  
  static int
diff -cr PyCVS/Objects/classobject.c PyMem/Objects/classobject.c
*** PyCVS/Objects/classobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/classobject.c	Sun Apr 30 07:25:15 2000
***************
*** 147,153 ****
  	Py_XDECREF(op->cl_getattr);
  	Py_XDECREF(op->cl_setattr);
  	Py_XDECREF(op->cl_delattr);
! 	free((ANY *)op);
  }
  
  static PyObject *
--- 147,153 ----
  	Py_XDECREF(op->cl_getattr);
  	Py_XDECREF(op->cl_setattr);
  	Py_XDECREF(op->cl_delattr);
! 	PyObject_DEL(op);
  }
  
  static PyObject *
***************
*** 561,567 ****
  #endif /* Py_TRACE_REFS */
  	Py_DECREF(inst->in_class);
  	Py_XDECREF(inst->in_dict);
! 	free((ANY *)inst);
  }
  
  static PyObject *
--- 561,567 ----
  #endif /* Py_TRACE_REFS */
  	Py_DECREF(inst->in_class);
  	Py_XDECREF(inst->in_dict);
! 	PyObject_DEL(inst);
  }
  
  static PyObject *
***************
*** 1498,1505 ****
  	im = free_list;
  	if (im != NULL) {
  		free_list = (PyMethodObject *)(im->im_self);
! 		im->ob_type = &PyMethod_Type;
! 		_Py_NewReference((PyObject *)im);
  	}
  	else {
  		im = PyObject_NEW(PyMethodObject, &PyMethod_Type);
--- 1498,1504 ----
  	im = free_list;
  	if (im != NULL) {
  		free_list = (PyMethodObject *)(im->im_self);
! 		PyObject_INIT(im, &PyMethod_Type);
  	}
  	else {
  		im = PyObject_NEW(PyMethodObject, &PyMethod_Type);
***************
*** 1691,1698 ****
  PyMethod_Fini()
  {
  	while (free_list) {
! 		PyMethodObject *v = free_list;
! 		free_list = (PyMethodObject *)(v->im_self);
! 		PyMem_DEL(v);
  	}
  }
--- 1690,1697 ----
  PyMethod_Fini()
  {
  	while (free_list) {
! 		PyMethodObject *im = free_list;
! 		free_list = (PyMethodObject *)(im->im_self);
! 		PyObject_DEL(im);
  	}
  }
diff -cr PyCVS/Objects/cobject.c PyMem/Objects/cobject.c
*** PyCVS/Objects/cobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/cobject.c	Sat Apr 29 23:31:09 2000
***************
*** 151,157 ****
  	    else
  	          (self->destructor)(self->cobject);
  	  }
! 	PyMem_DEL(self);
  }
  
  
--- 151,157 ----
  	    else
  	          (self->destructor)(self->cobject);
  	  }
! 	PyObject_DEL(self);
  }
  
  
diff -cr PyCVS/Objects/complexobject.c PyMem/Objects/complexobject.c
*** PyCVS/Objects/complexobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/complexobject.c	Sat Apr 29 23:31:23 2000
***************
*** 166,178 ****
  PyComplex_FromCComplex(cval)
  	Py_complex cval;
  {
! 	register PyComplexObject *op =
! 		(PyComplexObject *) malloc(sizeof(PyComplexObject));
  	if (op == NULL)
  		return PyErr_NoMemory();
! 	op->ob_type = &PyComplex_Type;
  	op->cval = cval;
- 	_Py_NewReference((PyObject *)op);
  	return (PyObject *) op;
  }
  
--- 166,179 ----
  PyComplex_FromCComplex(cval)
  	Py_complex cval;
  {
! 	register PyComplexObject *op;
! 
! 	/* PyObject_New is inlined */
! 	op = (PyComplexObject *) PyObject_MALLOC(sizeof(PyComplexObject));
  	if (op == NULL)
  		return PyErr_NoMemory();
! 	PyObject_INIT(op, &PyComplex_Type);
  	op->cval = cval;
  	return (PyObject *) op;
  }
  
***************
*** 226,232 ****
  complex_dealloc(op)
  	PyObject *op;
  {
! 	PyMem_DEL(op);
  }
  
  
--- 227,233 ----
  complex_dealloc(op)
  	PyObject *op;
  {
! 	PyObject_DEL(op);
  }
  
  
diff -cr PyCVS/Objects/dictobject.c PyMem/Objects/dictobject.c
*** PyCVS/Objects/dictobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/dictobject.c	Sun Apr 30 07:27:21 2000
***************
*** 277,283 ****
  			break;
  		}
  	}
! 	newtable = (dictentry *) malloc(sizeof(dictentry) * newsize);
  	if (newtable == NULL) {
  		PyErr_NoMemory();
  		return -1;
--- 277,283 ----
  			break;
  		}
  	}
! 	newtable = PyMem_NEW(dictentry, newsize);
  	if (newtable == NULL) {
  		PyErr_NoMemory();
  		return -1;
***************
*** 301,307 ****
  		}
  	}
  
! 	PyMem_XDEL(oldtable);
  	return 0;
  }
  
--- 301,308 ----
  		}
  	}
  
! 	if (oldtable != NULL)
! 		PyMem_DEL(oldtable);
  	return 0;
  }
  
***************
*** 488,495 ****
  			Py_DECREF(ep->me_value);
  		}
  	}
! 	PyMem_XDEL(mp->ma_table);
! 	PyMem_DEL(mp);
  	Py_TRASHCAN_SAFE_END(mp)
  }
  
--- 489,497 ----
  			Py_DECREF(ep->me_value);
  		}
  	}
! 	if (mp->ma_table != NULL)
! 		PyMem_DEL(mp->ma_table);
! 	PyObject_DEL(mp);
  	Py_TRASHCAN_SAFE_END(mp)
  }
  
diff -cr PyCVS/Objects/fileobject.c PyMem/Objects/fileobject.c
*** PyCVS/Objects/fileobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/fileobject.c	Sat Apr 29 23:41:14 2000
***************
*** 215,221 ****
  	if (f->f_mode != NULL) {
  		Py_DECREF(f->f_mode);
  	}
! 	free((char *)f);
  }
  
  static PyObject *
--- 215,221 ----
  	if (f->f_mode != NULL) {
  		Py_DECREF(f->f_mode);
  	}
! 	PyObject_DEL(f);
  }
  
  static PyObject *
diff -cr PyCVS/Objects/floatobject.c PyMem/Objects/floatobject.c
*** PyCVS/Objects/floatobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/floatobject.c	Sun Apr 30 09:22:23 2000
***************
*** 98,106 ****
  #define BHEAD_SIZE	8	/* Enough for a 64-bit pointer */
  #define N_FLOATOBJECTS	((BLOCK_SIZE - BHEAD_SIZE) / sizeof(PyFloatObject))
  
- #define PyMem_MALLOC	malloc
- #define PyMem_FREE	free
- 
  struct _floatblock {
  	struct _floatblock *next;
  	PyFloatObject objects[N_FLOATOBJECTS];
--- 98,103 ----
***************
*** 115,123 ****
  fill_free_list()
  {
  	PyFloatObject *p, *q;
! 	p = (PyFloatObject *)PyMem_MALLOC(sizeof(PyFloatBlock));
  	if (p == NULL)
! 		return (PyFloatObject *)PyErr_NoMemory();
  	((PyFloatBlock *)p)->next = block_list;
  	block_list = (PyFloatBlock *)p;
  	p = &((PyFloatBlock *)p)->objects[0];
--- 112,121 ----
  fill_free_list()
  {
  	PyFloatObject *p, *q;
! 	/* XXX Float blocks escape the object heap. Use PyObject_MALLOC ??? */
! 	p = (PyFloatObject *) PyMem_MALLOC(sizeof(PyFloatBlock));
  	if (p == NULL)
! 		return (PyFloatObject *) PyErr_NoMemory();
  	((PyFloatBlock *)p)->next = block_list;
  	block_list = (PyFloatBlock *)p;
  	p = &((PyFloatBlock *)p)->objects[0];
***************
*** 141,151 ****
  		if ((free_list = fill_free_list()) == NULL)
  			return NULL;
  	}
  	op = free_list;
  	free_list = (PyFloatObject *)op->ob_type;
! 	op->ob_type = &PyFloat_Type;
  	op->ob_fval = fval;
- 	_Py_NewReference((PyObject *)op);
  	return (PyObject *) op;
  }
  
--- 139,149 ----
  		if ((free_list = fill_free_list()) == NULL)
  			return NULL;
  	}
+ 	/* PyObject_New is inlined */
  	op = free_list;
  	free_list = (PyFloatObject *)op->ob_type;
! 	PyObject_INIT(op, &PyFloat_Type);
  	op->ob_fval = fval;
  	return (PyObject *) op;
  }
  
***************
*** 779,785 ****
  			}
  		}
  		else {
! 			PyMem_FREE(list);
  			bf++;
  		}
  		fsum += frem;
--- 777,783 ----
  			}
  		}
  		else {
! 			PyMem_FREE(list); /* XXX PyObject_FREE ??? */
  			bf++;
  		}
  		fsum += frem;
diff -cr PyCVS/Objects/frameobject.c PyMem/Objects/frameobject.c
*** PyCVS/Objects/frameobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/frameobject.c	Sun Apr 30 07:33:22 2000
***************
*** 180,207 ****
  	if (builtins != NULL && !PyDict_Check(builtins))
  		builtins = NULL;
  	if (free_list == NULL) {
  		f = (PyFrameObject *)
! 			malloc(sizeof(PyFrameObject) +
! 			       extras*sizeof(PyObject *));
  		if (f == NULL)
  			return (PyFrameObject *)PyErr_NoMemory();
! 		f->ob_type = &PyFrame_Type;
! 		_Py_NewReference((PyObject *)f);
  	}
  	else {
  		f = free_list;
  		free_list = free_list->f_back;
  		if (f->f_nlocals + f->f_stacksize < extras) {
  			f = (PyFrameObject *)
! 				realloc(f, sizeof(PyFrameObject) +
! 					extras*sizeof(PyObject *));
  			if (f == NULL)
  				return (PyFrameObject *)PyErr_NoMemory();
  		}
  		else
  			extras = f->f_nlocals + f->f_stacksize;
! 		f->ob_type = &PyFrame_Type;
! 		_Py_NewReference((PyObject *)f);
  	}
  	if (builtins == NULL) {
  		/* No builtins!  Make up a minimal one. */
--- 180,206 ----
  	if (builtins != NULL && !PyDict_Check(builtins))
  		builtins = NULL;
  	if (free_list == NULL) {
+ 		/* PyObject_New is inlined */
  		f = (PyFrameObject *)
! 			PyObject_MALLOC(sizeof(PyFrameObject) +
! 					extras*sizeof(PyObject *));
  		if (f == NULL)
  			return (PyFrameObject *)PyErr_NoMemory();
! 		PyObject_INIT(f, &PyFrame_Type);
  	}
  	else {
  		f = free_list;
  		free_list = free_list->f_back;
  		if (f->f_nlocals + f->f_stacksize < extras) {
  			f = (PyFrameObject *)
! 				PyObject_REALLOC(f, sizeof(PyFrameObject) +
! 						 extras*sizeof(PyObject *));
  			if (f == NULL)
  				return (PyFrameObject *)PyErr_NoMemory();
  		}
  		else
  			extras = f->f_nlocals + f->f_stacksize;
! 		PyObject_INIT(f, &PyFrame_Type);
  	}
  	if (builtins == NULL) {
  		/* No builtins!  Make up a minimal one. */
***************
*** 376,381 ****
  	while (free_list != NULL) {
  		PyFrameObject *f = free_list;
  		free_list = free_list->f_back;
! 		PyMem_DEL(f);
  	}
  }
--- 375,380 ----
  	while (free_list != NULL) {
  		PyFrameObject *f = free_list;
  		free_list = free_list->f_back;
! 		PyObject_DEL(f);
  	}
  }
diff -cr PyCVS/Objects/funcobject.c PyMem/Objects/funcobject.c
*** PyCVS/Objects/funcobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/funcobject.c	Sat Apr 29 23:55:01 2000
***************
*** 191,197 ****
  	Py_DECREF(op->func_name);
  	Py_XDECREF(op->func_defaults);
  	Py_XDECREF(op->func_doc);
! 	PyMem_DEL(op);
  }
  
  static PyObject*
--- 191,197 ----
  	Py_DECREF(op->func_name);
  	Py_XDECREF(op->func_defaults);
  	Py_XDECREF(op->func_doc);
! 	PyObject_DEL(op);
  }
  
  static PyObject*
diff -cr PyCVS/Objects/intobject.c PyMem/Objects/intobject.c
*** PyCVS/Objects/intobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/intobject.c	Sun Apr 30 09:23:01 2000
***************
*** 94,102 ****
  #define BHEAD_SIZE	8	/* Enough for a 64-bit pointer */
  #define N_INTOBJECTS	((BLOCK_SIZE - BHEAD_SIZE) / sizeof(PyIntObject))
  
- #define PyMem_MALLOC	malloc
- #define PyMem_FREE	free
- 
  struct _intblock {
  	struct _intblock *next;
  	PyIntObject objects[N_INTOBJECTS];
--- 94,99 ----
***************
*** 111,119 ****
  fill_free_list()
  {
  	PyIntObject *p, *q;
! 	p = (PyIntObject *)PyMem_MALLOC(sizeof(PyIntBlock));
  	if (p == NULL)
! 		return (PyIntObject *)PyErr_NoMemory();
  	((PyIntBlock *)p)->next = block_list;
  	block_list = (PyIntBlock *)p;
  	p = &((PyIntBlock *)p)->objects[0];
--- 108,117 ----
  fill_free_list()
  {
  	PyIntObject *p, *q;
! 	/* XXX Int blocks escape the object heap. Use PyObject_MALLOC ??? */
! 	p = (PyIntObject *) PyMem_MALLOC(sizeof(PyIntBlock));
  	if (p == NULL)
! 		return (PyIntObject *) PyErr_NoMemory();
  	((PyIntBlock *)p)->next = block_list;
  	block_list = (PyIntBlock *)p;
  	p = &((PyIntBlock *)p)->objects[0];
***************
*** 164,174 ****
  		if ((free_list = fill_free_list()) == NULL)
  			return NULL;
  	}
  	v = free_list;
  	free_list = (PyIntObject *)v->ob_type;
! 	v->ob_type = &PyInt_Type;
  	v->ob_ival = ival;
- 	_Py_NewReference((PyObject *)v);
  #if NSMALLNEGINTS + NSMALLPOSINTS > 0
  	if (-NSMALLNEGINTS <= ival && ival < NSMALLPOSINTS) {
  		/* save this one for a following allocation */
--- 162,172 ----
  		if ((free_list = fill_free_list()) == NULL)
  			return NULL;
  	}
+ 	/* PyObject_New is inlined */
  	v = free_list;
  	free_list = (PyIntObject *)v->ob_type;
! 	PyObject_INIT(v, &PyInt_Type);
  	v->ob_ival = ival;
  #if NSMALLNEGINTS + NSMALLPOSINTS > 0
  	if (-NSMALLNEGINTS <= ival && ival < NSMALLPOSINTS) {
  		/* save this one for a following allocation */
***************
*** 933,939 ****
  			}
  		}
  		else {
! 			PyMem_FREE(list);
  			bf++;
  		}
  		isum += irem;
--- 931,937 ----
  			}
  		}
  		else {
! 			PyMem_FREE(list); /* XXX PyObject_FREE ??? */
  			bf++;
  		}
  		isum += irem;
diff -cr PyCVS/Objects/listobject.c PyMem/Objects/listobject.c
*** PyCVS/Objects/listobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/listobject.c	Sun Apr 30 00:48:14 2000
***************
*** 70,76 ****
  	if (nbytes / sizeof(PyObject *) != (size_t)size) {
  		return PyErr_NoMemory();
  	}
! 	op = (PyListObject *) malloc(sizeof(PyListObject));
  	if (op == NULL) {
  		return PyErr_NoMemory();
  	}
--- 70,77 ----
  	if (nbytes / sizeof(PyObject *) != (size_t)size) {
  		return PyErr_NoMemory();
  	}
! 	/* PyObject_NewVar is inlined */
! 	op = (PyListObject *) PyObject_MALLOC(sizeof(PyListObject));
  	if (op == NULL) {
  		return PyErr_NoMemory();
  	}
***************
*** 78,94 ****
  		op->ob_item = NULL;
  	}
  	else {
! 		op->ob_item = (PyObject **) malloc(nbytes);
  		if (op->ob_item == NULL) {
! 			free((ANY *)op);
  			return PyErr_NoMemory();
  		}
  	}
! 	op->ob_type = &PyList_Type;
! 	op->ob_size = size;
  	for (i = 0; i < size; i++)
  		op->ob_item[i] = NULL;
- 	_Py_NewReference((PyObject *)op);
  	return (PyObject *) op;
  }
  
--- 79,93 ----
  		op->ob_item = NULL;
  	}
  	else {
! 		op->ob_item = (PyObject **) PyMem_MALLOC(nbytes);
  		if (op->ob_item == NULL) {
! 			PyObject_FREE(op);
  			return PyErr_NoMemory();
  		}
  	}
! 	PyObject_INIT_VAR(op, &PyList_Type, size);
  	for (i = 0; i < size; i++)
  		op->ob_item[i] = NULL;
  	return (PyObject *) op;
  }
  
***************
*** 225,233 ****
  		while (--i >= 0) {
  			Py_XDECREF(op->ob_item[i]);
  		}
! 		free((ANY *)op->ob_item);
  	}
! 	free((ANY *)op);
  	Py_TRASHCAN_SAFE_END(op)
  }
  
--- 224,232 ----
  		while (--i >= 0) {
  			Py_XDECREF(op->ob_item[i]);
  		}
! 		PyMem_FREE(op->ob_item);
  	}
! 	PyObject_DEL(op);
  	Py_TRASHCAN_SAFE_END(op)
  }
  
***************
*** 501,507 ****
  	else { /* Insert d items; recycle ihigh-ilow items */
  		NRESIZE(item, PyObject *, a->ob_size + d);
  		if (item == NULL) {
! 			PyMem_XDEL(recycle);
  			PyErr_NoMemory();
  			return -1;
  		}
--- 500,507 ----
  	else { /* Insert d items; recycle ihigh-ilow items */
  		NRESIZE(item, PyObject *, a->ob_size + d);
  		if (item == NULL) {
! 			if (recycle != NULL)
! 				PyMem_DEL(recycle);
  			PyErr_NoMemory();
  			return -1;
  		}
diff -cr PyCVS/Objects/longobject.c PyMem/Objects/longobject.c
*** PyCVS/Objects/longobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/longobject.c	Sun Apr 30 00:13:09 2000
***************
*** 995,1001 ****
  long_dealloc(v)
  	PyObject *v;
  {
! 	PyMem_DEL(v);
  }
  
  static PyObject *
--- 995,1001 ----
  long_dealloc(v)
  	PyObject *v;
  {
! 	PyObject_DEL(v);
  }
  
  static PyObject *
diff -cr PyCVS/Objects/methodobject.c PyMem/Objects/methodobject.c
*** PyCVS/Objects/methodobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/methodobject.c	Sun Apr 30 00:15:12 2000
***************
*** 46,53 ****
  	op = free_list;
  	if (op != NULL) {
  		free_list = (PyCFunctionObject *)(op->m_self);
! 		op->ob_type = &PyCFunction_Type;
! 		_Py_NewReference((PyObject *)op);
  	}
  	else {
  		op = PyObject_NEW(PyCFunctionObject, &PyCFunction_Type);
--- 46,52 ----
  	op = free_list;
  	if (op != NULL) {
  		free_list = (PyCFunctionObject *)(op->m_self);
! 		PyObject_INIT(op, &PyCFunction_Type);
  	}
  	else {
  		op = PyObject_NEW(PyCFunctionObject, &PyCFunction_Type);
***************
*** 288,293 ****
  	while (free_list) {
  		PyCFunctionObject *v = free_list;
  		free_list = (PyCFunctionObject *)(v->m_self);
! 		PyMem_DEL(v);
  	}
  }
--- 287,292 ----
  	while (free_list) {
  		PyCFunctionObject *v = free_list;
  		free_list = (PyCFunctionObject *)(v->m_self);
! 		PyObject_DEL(v);
  	}
  }
diff -cr PyCVS/Objects/moduleobject.c PyMem/Objects/moduleobject.c
*** PyCVS/Objects/moduleobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/moduleobject.c	Sun Apr 30 00:16:34 2000
***************
*** 170,176 ****
  		_PyModule_Clear((PyObject *)m);
  		Py_DECREF(m->md_dict);
  	}
! 	free((char *)m);
  }
  
  static PyObject *
--- 170,176 ----
  		_PyModule_Clear((PyObject *)m);
  		Py_DECREF(m->md_dict);
  	}
! 	PyObject_DEL(m);
  }
  
  static PyObject *
diff -cr PyCVS/Objects/object.c PyMem/Objects/object.c
*** PyCVS/Objects/object.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/object.c	Sun Apr 30 07:34:17 2000
***************
*** 112,161 ****
  }
  #endif
  
- #ifndef MS_COREDLL
  PyObject *
! _PyObject_New(tp)
! 	PyTypeObject *tp;
! #else
! PyObject *
! _PyObject_New(tp,op)
! 	PyTypeObject *tp;
  	PyObject *op;
! #endif
  {
! #ifndef MS_COREDLL
! 	PyObject *op = (PyObject *) malloc(tp->tp_basicsize);
! #endif
! 	if (op == NULL)
! 		return PyErr_NoMemory();
! 	op->ob_type = tp;
  	_Py_NewReference(op);
  	return op;
  }
  
- #ifndef MS_COREDLL
  PyVarObject *
! _PyObject_NewVar(tp, size)
  	PyTypeObject *tp;
  	int size;
! #else
  PyVarObject *
! _PyObject_NewVar(tp, size, op)
  	PyTypeObject *tp;
  	int size;
- 	PyVarObject *op;
- #endif
  {
! #ifndef MS_COREDLL
! 	PyVarObject *op = (PyVarObject *)
! 		malloc(tp->tp_basicsize + size * tp->tp_itemsize);
! #endif
  	if (op == NULL)
  		return (PyVarObject *)PyErr_NoMemory();
! 	op->ob_type = tp;
! 	op->ob_size = size;
! 	_Py_NewReference((PyObject *)op);
! 	return op;
  }
  
  int
--- 112,179 ----
  }
  #endif
  
  PyObject *
! PyObject_Init(op, tp)
  	PyObject *op;
! 	PyTypeObject *tp;
  {
! 	if (op == NULL) {
! 		PyErr_SetString(PyExc_SystemError,
! 				"NULL object passed to PyObject_Init");
! 		return op;
!   	}
! 	/* Any changes should be reflected in PyObject_INIT (objimpl.h) */
  	_Py_NewReference(op);
+ 	op->ob_type = tp;
  	return op;
  }
  
  PyVarObject *
! PyObject_InitVar(op, tp, size)
! 	PyVarObject *op;
  	PyTypeObject *tp;
  	int size;
! {
! 	if (op == NULL) {
! 		PyErr_SetString(PyExc_SystemError,
! 				"NULL object passed to PyObject_InitVar");
! 		return op;
! 	}
! 	/* Any changes should be reflected in PyObject_INIT_VAR */
! 	_Py_NewReference(op);
! 	op->ob_type = tp;
! 	op->ob_size = size;
! 	return op;
! }
! 
! PyObject *
! _PyObject_New(tp)
! 	PyTypeObject *tp;
! {
! 	PyObject *op;
! 	op = (PyObject *) PyObject_MALLOC(_PyObject_SIZE(tp));
! 	if (op == NULL)
! 		return PyErr_NoMemory();
! 	return PyObject_INIT(op, tp);
! }
! 
  PyVarObject *
! _PyObject_NewVar(tp, size)
  	PyTypeObject *tp;
  	int size;
  {
! 	PyVarObject *op;
! 	op = (PyVarObject *) PyObject_MALLOC(_PyObject_VAR_SIZE(tp, size));
  	if (op == NULL)
  		return (PyVarObject *)PyErr_NoMemory();
! 	return PyObject_INIT_VAR(op, tp, size);
! }
! 
! void
! _PyObject_Del(op)
! 	PyObject *op;
! {
! 	PyObject_FREE(op);
  }
  
  int
***************
*** 888,917 ****
  int (*_Py_abstract_hack) Py_FPROTO((PyObject *)) = &PyObject_Length;
  
  
! /* Malloc wrappers (see mymalloc.h) */
! 
! /* The Py_{Malloc,Realloc} wrappers call PyErr_NoMemory() on failure */
  
  ANY *
! Py_Malloc(nbytes)
  	size_t nbytes;
  {
- 	ANY *p;
  #if _PyMem_EXTRA > 0
  	if (nbytes == 0)
  		nbytes = _PyMem_EXTRA;
  #endif
! 	p = malloc(nbytes);
! 	if (p != NULL)
! 		return p;
! 	else {
! 		PyErr_NoMemory();
! 		return NULL;
! 	}
  }
  
  ANY *
! Py_Realloc(p, nbytes)
  	ANY *p;
  	size_t nbytes;
  {
--- 906,926 ----
  int (*_Py_abstract_hack) Py_FPROTO((PyObject *)) = &PyObject_Length;
  
  
! /* Python's malloc wrappers (see mymalloc.h) */
  
  ANY *
! PyMem_Malloc(nbytes)
  	size_t nbytes;
  {
  #if _PyMem_EXTRA > 0
  	if (nbytes == 0)
  		nbytes = _PyMem_EXTRA;
  #endif
! 	return PyMem_MALLOC(nbytes);
  }
  
  ANY *
! PyMem_Realloc(p, nbytes)
  	ANY *p;
  	size_t nbytes;
  {
***************
*** 919,970 ****
  	if (nbytes == 0)
  		nbytes = _PyMem_EXTRA;
  #endif
! 	p = realloc(p, nbytes);
! 	if (p != NULL)
! 		return p;
! 	else {
! 		PyErr_NoMemory();
! 		return NULL;
! 	}
  }
  
  void
! Py_Free(p)
  	ANY *p;
  {
! 	free(p);
  }
  
! /* The PyMem_{Malloc,Realloc} wrappers don't call anything on failure */
  
  ANY *
! PyMem_Malloc(nbytes)
  	size_t nbytes;
  {
! #if _PyMem_EXTRA > 0
! 	if (nbytes == 0)
! 		nbytes = _PyMem_EXTRA;
! #endif
! 	return malloc(nbytes);
  }
  
  ANY *
! PyMem_Realloc(p, nbytes)
  	ANY *p;
  	size_t nbytes;
  {
! #if _PyMem_EXTRA > 0
! 	if (nbytes == 0)
! 		nbytes = _PyMem_EXTRA;
! #endif
! 	return realloc(p, nbytes);
  }
  
  void
! PyMem_Free(p)
  	ANY *p;
  {
! 	free(p);
  }
  
  
--- 928,966 ----
  	if (nbytes == 0)
  		nbytes = _PyMem_EXTRA;
  #endif
! 	return PyMem_REALLOC(p, nbytes);
  }
  
  void
! PyMem_Free(p)
  	ANY *p;
  {
! 	PyMem_FREE(p);
  }
  
! 
! /* Python's object malloc wrappers (see objimpl.h) */
  
  ANY *
! PyObject_Malloc(nbytes)
  	size_t nbytes;
  {
! 	return PyObject_MALLOC(nbytes);
  }
  
  ANY *
! PyObject_Realloc(p, nbytes)
  	ANY *p;
  	size_t nbytes;
  {
! 	return PyObject_REALLOC(p, nbytes);
  }
  
  void
! PyObject_Free(p)
  	ANY *p;
  {
! 	PyObject_FREE(p);
  }
  
  
diff -cr PyCVS/Objects/rangeobject.c PyMem/Objects/rangeobject.c
*** PyCVS/Objects/rangeobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/rangeobject.c	Sun Apr 30 00:33:25 2000
***************
*** 61,67 ****
  range_dealloc(r)
  	rangeobject *r;
  {
! 	PyMem_DEL(r);
  }
  
  static PyObject *
--- 61,67 ----
  range_dealloc(r)
  	rangeobject *r;
  {
! 	PyObject_DEL(r);
  }
  
  static PyObject *
diff -cr PyCVS/Objects/sliceobject.c PyMem/Objects/sliceobject.c
*** PyCVS/Objects/sliceobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/sliceobject.c	Sun Apr 30 00:44:54 2000
***************
*** 57,64 ****
  	PyObject *stop;
  	PyObject *step;
  {
! 	PySliceObject *obj =
! 		(PySliceObject *) PyObject_NEW(PySliceObject, &PySlice_Type);
  
  	if (step == NULL) step = Py_None;
  	Py_INCREF(step);
--- 57,63 ----
  	PyObject *stop;
  	PyObject *step;
  {
! 	PySliceObject *obj = PyObject_NEW(PySliceObject, &PySlice_Type);
  
  	if (step == NULL) step = Py_None;
  	Py_INCREF(step);
***************
*** 115,121 ****
  	Py_DECREF(r->step);
  	Py_DECREF(r->start);
  	Py_DECREF(r->stop);
! 	PyMem_DEL(r);
  }
  
  static PyObject *
--- 114,120 ----
  	Py_DECREF(r->step);
  	Py_DECREF(r->start);
  	Py_DECREF(r->stop);
! 	PyObject_DEL(r);
  }
  
  static PyObject *
diff -cr PyCVS/Objects/stringobject.c PyMem/Objects/stringobject.c
*** PyCVS/Objects/stringobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/stringobject.c	Sun Apr 30 01:02:47 2000
***************
*** 92,110 ****
  		return (PyObject *)op;
  	}
  #endif /* DONT_SHARE_SHORT_STRINGS */
  	op = (PyStringObject *)
! 		malloc(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
! 	op->ob_type = &PyString_Type;
! 	op->ob_size = size;
  #ifdef CACHE_HASH
  	op->ob_shash = -1;
  #endif
  #ifdef INTERN_STRINGS
  	op->ob_sinterned = NULL;
  #endif
- 	_Py_NewReference((PyObject *)op);
  	if (str != NULL)
  		memcpy(op->ob_sval, str, size);
  	op->ob_sval[size] = '\0';
--- 92,110 ----
  		return (PyObject *)op;
  	}
  #endif /* DONT_SHARE_SHORT_STRINGS */
+ 
+ 	/* PyObject_NewVar is inlined */
  	op = (PyStringObject *)
! 		PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
! 	PyObject_INIT_VAR(op, &PyString_Type, size);
  #ifdef CACHE_HASH
  	op->ob_shash = -1;
  #endif
  #ifdef INTERN_STRINGS
  	op->ob_sinterned = NULL;
  #endif
  	if (str != NULL)
  		memcpy(op->ob_sval, str, size);
  	op->ob_sval[size] = '\0';
***************
*** 142,160 ****
  		return (PyObject *)op;
  	}
  #endif /* DONT_SHARE_SHORT_STRINGS */
  	op = (PyStringObject *)
! 		malloc(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
! 	op->ob_type = &PyString_Type;
! 	op->ob_size = size;
  #ifdef CACHE_HASH
  	op->ob_shash = -1;
  #endif
  #ifdef INTERN_STRINGS
  	op->ob_sinterned = NULL;
  #endif
- 	_Py_NewReference((PyObject *)op);
  	strcpy(op->ob_sval, str);
  #ifndef DONT_SHARE_SHORT_STRINGS
  	if (size == 0) {
--- 142,160 ----
  		return (PyObject *)op;
  	}
  #endif /* DONT_SHARE_SHORT_STRINGS */
+ 
+ 	/* PyObject_NewVar is inlined */
  	op = (PyStringObject *)
! 		PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
! 	PyObject_INIT_VAR(op, &PyString_Type, size);
  #ifdef CACHE_HASH
  	op->ob_shash = -1;
  #endif
  #ifdef INTERN_STRINGS
  	op->ob_sinterned = NULL;
  #endif
  	strcpy(op->ob_sval, str);
  #ifndef DONT_SHARE_SHORT_STRINGS
  	if (size == 0) {
***************
*** 172,178 ****
  string_dealloc(op)
  	PyObject *op;
  {
! 	PyMem_DEL(op);
  }
  
  int
--- 172,178 ----
  string_dealloc(op)
  	PyObject *op;
  {
! 	PyObject_DEL(op);
  }
  
  int
***************
*** 307,325 ****
  		return (PyObject *)a;
  	}
  	size = a->ob_size + b->ob_size;
  	op = (PyStringObject *)
! 		malloc(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
! 	op->ob_type = &PyString_Type;
! 	op->ob_size = size;
  #ifdef CACHE_HASH
  	op->ob_shash = -1;
  #endif
  #ifdef INTERN_STRINGS
  	op->ob_sinterned = NULL;
  #endif
- 	_Py_NewReference((PyObject *)op);
  	memcpy(op->ob_sval, a->ob_sval, (int) a->ob_size);
  	memcpy(op->ob_sval + a->ob_size, b->ob_sval, (int) b->ob_size);
  	op->ob_sval[size] = '\0';
--- 307,324 ----
  		return (PyObject *)a;
  	}
  	size = a->ob_size + b->ob_size;
+ 	/* PyObject_NewVar is inlined */
  	op = (PyStringObject *)
! 		PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
! 	PyObject_INIT_VAR(op, &PyString_Type, size);
  #ifdef CACHE_HASH
  	op->ob_shash = -1;
  #endif
  #ifdef INTERN_STRINGS
  	op->ob_sinterned = NULL;
  #endif
  	memcpy(op->ob_sval, a->ob_sval, (int) a->ob_size);
  	memcpy(op->ob_sval + a->ob_size, b->ob_sval, (int) b->ob_size);
  	op->ob_sval[size] = '\0';
***************
*** 342,360 ****
  		Py_INCREF(a);
  		return (PyObject *)a;
  	}
  	op = (PyStringObject *)
! 		malloc(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
! 	op->ob_type = &PyString_Type;
! 	op->ob_size = size;
  #ifdef CACHE_HASH
  	op->ob_shash = -1;
  #endif
  #ifdef INTERN_STRINGS
  	op->ob_sinterned = NULL;
  #endif
- 	_Py_NewReference((PyObject *)op);
  	for (i = 0; i < size; i += a->ob_size)
  		memcpy(op->ob_sval+i, a->ob_sval, (int) a->ob_size);
  	op->ob_sval[size] = '\0';
--- 341,358 ----
  		Py_INCREF(a);
  		return (PyObject *)a;
  	}
+ 	/* PyObject_NewVar is inlined */
  	op = (PyStringObject *)
! 		PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
! 	PyObject_INIT_VAR(op, &PyString_Type, size);
  #ifdef CACHE_HASH
  	op->ob_shash = -1;
  #endif
  #ifdef INTERN_STRINGS
  	op->ob_sinterned = NULL;
  #endif
  	for (i = 0; i < size; i += a->ob_size)
  		memcpy(op->ob_sval+i, a->ob_sval, (int) a->ob_size);
  	op->ob_sval[size] = '\0';
***************
*** 1498,1504 ****
  		goto return_same;
  	new_len = len + nfound*(sub_len - pat_len);
  
! 	new_s = (char *)malloc(new_len);
  	if (new_s == NULL) return NULL;
  
  	*out_len = new_len;
--- 1496,1502 ----
  		goto return_same;
  	new_len = len + nfound*(sub_len - pat_len);
  
! 	new_s = (char *)PyMem_MALLOC(new_len);
  	if (new_s == NULL) return NULL;
  
  	*out_len = new_len;
***************
*** 1593,1599 ****
  	}
  	else {
  		new = PyString_FromStringAndSize(new_s, out_len);
! 		free(new_s);
  	}
  	return new;
  }
--- 1591,1597 ----
  	}
  	else {
  		new = PyString_FromStringAndSize(new_s, out_len);
! 		PyMem_FREE(new_s);
  	}
  	return new;
  }
***************
*** 2273,2282 ****
  #endif
  	_Py_ForgetReference(v);
  	*pv = (PyObject *)
! 		realloc((char *)v,
  			sizeof(PyStringObject) + newsize * sizeof(char));
  	if (*pv == NULL) {
! 		PyMem_DEL(v);
  		PyErr_NoMemory();
  		return -1;
  	}
--- 2271,2280 ----
  #endif
  	_Py_ForgetReference(v);
  	*pv = (PyObject *)
! 		PyObject_REALLOC((char *)v,
  			sizeof(PyStringObject) + newsize * sizeof(char));
  	if (*pv == NULL) {
! 		PyObject_DEL(v);
  		PyErr_NoMemory();
  		return -1;
  	}
diff -cr PyCVS/Objects/tupleobject.c PyMem/Objects/tupleobject.c
*** PyCVS/Objects/tupleobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/tupleobject.c	Sun Apr 30 01:20:11 2000
***************
*** 77,89 ****
  	{
  		free_tuples[size] = (PyTupleObject *) op->ob_item[0];
  		num_free_tuples[size]--;
  #ifdef COUNT_ALLOCS
  		fast_tuple_allocs++;
  #endif
- #ifdef Py_TRACE_REFS
- 		op->ob_type = &PyTuple_Type;
- 		op->ob_size = size;
- #endif
  	}
  	else
  #endif
--- 77,89 ----
  	{
  		free_tuples[size] = (PyTupleObject *) op->ob_item[0];
  		num_free_tuples[size]--;
+ 		_Py_NewReference((PyObject *)op);
+ #ifdef Py_TRACE_REFS
+ 		PyObject_INIT_VAR(op, &PyTuple_Type, size);
+ #endif
  #ifdef COUNT_ALLOCS
  		fast_tuple_allocs++;
  #endif
  	}
  	else
  #endif
***************
*** 96,112 ****
  		{
  			return PyErr_NoMemory();
  		}
! 		;
! 		op = (PyTupleObject *) malloc(nbytes);
  		if (op == NULL)
  			return PyErr_NoMemory();
  
! 		op->ob_type = &PyTuple_Type;
! 		op->ob_size = size;
  	}
  	for (i = 0; i < size; i++)
  		op->ob_item[i] = NULL;
- 	_Py_NewReference((PyObject *)op);
  #if MAXSAVESIZE > 0
  	if (size == 0) {
  		free_tuples[0] = op;
--- 96,110 ----
  		{
  			return PyErr_NoMemory();
  		}
! 		/* PyObject_NewVar is inlined */
! 		op = (PyTupleObject *) PyObject_MALLOC(nbytes);
  		if (op == NULL)
  			return PyErr_NoMemory();
  
! 		PyObject_INIT_VAR(op, &PyTuple_Type, size);
  	}
  	for (i = 0; i < size; i++)
  		op->ob_item[i] = NULL;
  #if MAXSAVESIZE > 0
  	if (size == 0) {
  		free_tuples[0] = op;
***************
*** 193,199 ****
  		}
  #endif
  	}
! 	free((ANY *)op);
  done:
  	Py_TRASHCAN_SAFE_END(op)
  }
--- 191,197 ----
  		}
  #endif
  	}
! 	PyObject_DEL(op);
  done:
  	Py_TRASHCAN_SAFE_END(op)
  }
***************
*** 530,540 ****
  #endif		
  	{
  		sv = (PyTupleObject *)
! 			realloc((char *)v,
  				sizeof(PyTupleObject) + newsize * sizeof(PyObject *));
  		*pv = (PyObject *) sv;
  		if (sv == NULL) {
! 			PyMem_DEL(v);
  			PyErr_NoMemory();
  			return -1;
  		}
--- 528,538 ----
  #endif		
  	{
  		sv = (PyTupleObject *)
! 			PyObject_REALLOC((char *)v,
  				sizeof(PyTupleObject) + newsize * sizeof(PyObject *));
  		*pv = (PyObject *) sv;
  		if (sv == NULL) {
! 			PyObject_DEL(v);
  			PyErr_NoMemory();
  			return -1;
  		}
***************
*** 569,575 ****
  		while (p) {
  			q = p;
  			p = (PyTupleObject *)(p->ob_item[0]);
! 			PyMem_DEL(q);
  		}
  	}
  #endif
--- 567,573 ----
  		while (p) {
  			q = p;
  			p = (PyTupleObject *)(p->ob_item[0]);
! 			PyObject_DEL(q);
  		}
  	}
  #endif
diff -cr PyCVS/Objects/unicodeobject.c PyMem/Objects/unicodeobject.c
*** PyCVS/Objects/unicodeobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/unicodeobject.c	Sun Apr 30 08:01:31 2000
***************
*** 200,213 ****
          unicode = unicode_freelist;
          unicode_freelist = *(PyUnicodeObject **)unicode_freelist;
          unicode_freelist_size--;
!         unicode->ob_type = &PyUnicode_Type;
!         _Py_NewReference((PyObject *)unicode);
  	if (unicode->str) {
  	    /* Keep-Alive optimization: we only upsize the buffer,
  	       never downsize it. */
  	    if ((unicode->length < length) &&
  		_PyUnicode_Resize(unicode, length)) {
! 		free(unicode->str);
  		goto onError;
  	    }
  	}
--- 200,212 ----
          unicode = unicode_freelist;
          unicode_freelist = *(PyUnicodeObject **)unicode_freelist;
          unicode_freelist_size--;
! 	PyObject_INIT(unicode, &PyUnicode_Type);
  	if (unicode->str) {
  	    /* Keep-Alive optimization: we only upsize the buffer,
  	       never downsize it. */
  	    if ((unicode->length < length) &&
  		_PyUnicode_Resize(unicode, length)) {
! 		PyMem_DEL(unicode->str);
  		goto onError;
  	    }
  	}
***************
*** 233,239 ****
  
   onError:
      _Py_ForgetReference((PyObject *)unicode);
!     PyMem_DEL(unicode);
      return NULL;
  }
  
--- 232,238 ----
  
   onError:
      _Py_ForgetReference((PyObject *)unicode);
!     PyObject_DEL(unicode);
      return NULL;
  }
  
***************
*** 243,249 ****
      if (unicode_freelist_size < MAX_UNICODE_FREELIST_SIZE) {
          /* Keep-Alive optimization */
  	if (unicode->length >= KEEPALIVE_SIZE_LIMIT) {
! 	    free(unicode->str);
  	    unicode->str = NULL;
  	    unicode->length = 0;
  	}
--- 242,248 ----
      if (unicode_freelist_size < MAX_UNICODE_FREELIST_SIZE) {
          /* Keep-Alive optimization */
  	if (unicode->length >= KEEPALIVE_SIZE_LIMIT) {
! 	    PyMem_DEL(unicode->str);
  	    unicode->str = NULL;
  	    unicode->length = 0;
  	}
***************
*** 257,265 ****
          unicode_freelist_size++;
      }
      else {
! 	free(unicode->str);
  	Py_XDECREF(unicode->utf8str);
!         PyMem_DEL(unicode);
      }
  }
  
--- 256,264 ----
          unicode_freelist_size++;
      }
      else {
! 	PyMem_DEL(unicode->str);
  	Py_XDECREF(unicode->utf8str);
! 	PyObject_DEL(unicode);
      }
  }
  
***************
*** 4662,4670 ****
  	PyUnicodeObject *v = u;
  	u = *(PyUnicodeObject **)u;
  	if (v->str)
! 	    free(v->str);
  	Py_XDECREF(v->utf8str);
! 	free(v);
      }
      Py_XDECREF(unicode_empty);
  }
--- 4661,4669 ----
  	PyUnicodeObject *v = u;
  	u = *(PyUnicodeObject **)u;
  	if (v->str)
! 	    PyMem_DEL(v->str);
  	Py_XDECREF(v->utf8str);
! 	PyObject_DEL(v);
      }
      Py_XDECREF(unicode_empty);
  }
diff -cr PyCVS/Objects/xxobject.c PyMem/Objects/xxobject.c
*** PyCVS/Objects/xxobject.c	Sat Apr 29 00:24:07 2000
--- PyMem/Objects/xxobject.c	Sun Apr 30 08:02:58 2000
***************
*** 71,77 ****
  	xxobject *xp;
  {
  	Py_XDECREF(xp->x_attr);
! 	PyMem_DEL(xp);
  }
  
  static PyObject *
--- 71,77 ----
  	xxobject *xp;
  {
  	Py_XDECREF(xp->x_attr);
! 	PyObject_DEL(xp);
  }
  
  static PyObject *