[Python-checkins] CVS: python/dist/src/Modules _weakref.c,1.11,1.12
Fred L. Drake
fdrake@users.sourceforge.net
Thu, 16 Aug 2001 07:11:32 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv5764
Modified Files:
_weakref.c
Log Message:
Use METH_O where possible (two functions). This does not lead to real
performance changes since the affected functions are not expected to be
used frequently, but reduces the volume of code.
Index: _weakref.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_weakref.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** _weakref.c 2001/05/03 16:05:46 1.11
--- _weakref.c 2001/08/16 14:11:30 1.12
***************
*** 505,522 ****
static PyObject *
! weakref_getweakrefcount(PyObject *self, PyObject *args)
{
PyObject *result = NULL;
- PyObject *object;
! if (PyArg_ParseTuple(args, "O:getweakrefcount", &object)) {
! if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) {
! PyWeakReference **list = GET_WEAKREFS_LISTPTR(object);
! result = PyInt_FromLong(getweakrefcount(*list));
! }
! else
! result = PyInt_FromLong(0);
}
return result;
}
--- 505,520 ----
static PyObject *
! weakref_getweakrefcount(PyObject *self, PyObject *object)
{
PyObject *result = NULL;
! if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) {
! PyWeakReference **list = GET_WEAKREFS_LISTPTR(object);
! result = PyInt_FromLong(getweakrefcount(*list));
}
+ else
+ result = PyInt_FromLong(0);
+
return result;
}
***************
*** 528,556 ****
static PyObject *
! weakref_getweakrefs(PyObject *self, PyObject *args)
{
PyObject *result = NULL;
- PyObject *object;
! if (PyArg_ParseTuple(args, "O:getweakrefs", &object)) {
! if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) {
! PyWeakReference **list = GET_WEAKREFS_LISTPTR(object);
! long count = getweakrefcount(*list);
! result = PyList_New(count);
! if (result != NULL) {
! PyWeakReference *current = *list;
! long i;
! for (i = 0; i < count; ++i) {
! PyList_SET_ITEM(result, i, (PyObject *) current);
! Py_INCREF(current);
! current = current->wr_next;
! }
}
}
- else {
- result = PyList_New(0);
- }
}
return result;
}
--- 526,551 ----
static PyObject *
! weakref_getweakrefs(PyObject *self, PyObject *object)
{
PyObject *result = NULL;
! if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) {
! PyWeakReference **list = GET_WEAKREFS_LISTPTR(object);
! long count = getweakrefcount(*list);
! result = PyList_New(count);
! if (result != NULL) {
! PyWeakReference *current = *list;
! long i;
! for (i = 0; i < count; ++i) {
! PyList_SET_ITEM(result, i, (PyObject *) current);
! Py_INCREF(current);
! current = current->wr_next;
}
}
}
+ else {
+ result = PyList_New(0);
+ }
return result;
}
***************
*** 797,803 ****
static PyMethodDef
weakref_functions[] = {
! {"getweakrefcount", weakref_getweakrefcount, METH_VARARGS,
weakref_getweakrefcount__doc__},
! {"getweakrefs", weakref_getweakrefs, METH_VARARGS,
weakref_getweakrefs__doc__},
{"proxy", weakref_proxy, METH_VARARGS,
--- 792,798 ----
static PyMethodDef
weakref_functions[] = {
! {"getweakrefcount", weakref_getweakrefcount, METH_O,
weakref_getweakrefcount__doc__},
! {"getweakrefs", weakref_getweakrefs, METH_O,
weakref_getweakrefs__doc__},
{"proxy", weakref_proxy, METH_VARARGS,