summaryrefslogtreecommitdiff
path: root/Include/objimpl.h
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-03-22 18:26:47 +0000
committerFred Drake <fdrake@acm.org>2001-03-22 18:26:47 +0000
commit4e262a963190b201578b0b5d972035b1637f6bd5 (patch)
tree8c1e035b25075b1fb03f71d101260984d58a0e7c /Include/objimpl.h
parent82f1480d63a43c2007460e8f186aba8d0fc4ce38 (diff)
downloadcpython-git-4e262a963190b201578b0b5d972035b1637f6bd5.tar.gz
A small change to the C API for weakly-referencable types: Such types
must now initialize the extra field used by the weak-ref machinery to NULL themselves, to avoid having to require PyObject_INIT() to check if the type supports weak references and do it there. This causes less work to be done for all objects (the type object does not need to be consulted to check for the Py_TPFLAGS_HAVE_WEAKREFS bit).
Diffstat (limited to 'Include/objimpl.h')
-rw-r--r--Include/objimpl.h6
1 files changed, 1 insertions, 5 deletions
diff --git a/Include/objimpl.h b/Include/objimpl.h
index 4197bde3e1..4aa38d5673 100644
--- a/Include/objimpl.h
+++ b/Include/objimpl.h
@@ -167,11 +167,7 @@ extern DL_IMPORT(void) _PyObject_Del(PyObject *);
/* Macros trading binary compatibility for speed. See also pymem.h.
Note that these macros expect non-NULL object pointers.*/
#define PyObject_INIT(op, typeobj) \
- ((op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), \
- (PyType_SUPPORTS_WEAKREFS((typeobj)) \
- ? *(PyObject_GET_WEAKREFS_LISTPTR(op)) = NULL \
- : NULL), \
- (op))
+ ( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
#define PyObject_INIT_VAR(op, typeobj, size) \
( (op)->ob_size = (size), PyObject_INIT((op), (typeobj)) )