]> granicus.if.org Git - python/commitdiff
Two new public API functions, Py_IncRef and Py_DecRef. Useful for
authorThomas Heller <theller@ctypes.org>
Thu, 22 Apr 2004 17:23:49 +0000 (17:23 +0000)
committerThomas Heller <theller@ctypes.org>
Thu, 22 Apr 2004 17:23:49 +0000 (17:23 +0000)
dynamic embedders of Python.

Doc/api/refcounting.tex
Include/object.h
Misc/NEWS
Objects/object.c

index 03530f09a9988d1e8e5e610c9b9543f1427f8687..42b9e6a156a30f16b16c3b619937229825f3bc8e 100644 (file)
@@ -42,6 +42,11 @@ of Python objects.
   applies.
 \end{cfuncdesc}
 
+The following functions are for runtime dynamic embedding of Python:
+\cfunction{Py_IncRef(PyObject *o)}, \cfunction{Py_DecRef(PyObject *o)}.
+They are simply exported function versions of \cfunction{Py_XINCREF()} and 
+\cfunction{Py_XDECREF()}, respectively.
+
 The following functions or macros are only for use within the
 interpreter core: \cfunction{_Py_Dealloc()},
 \cfunction{_Py_ForgetReference()}, \cfunction{_Py_NewReference()}, as
index f6135eecb35c5c85c718abb0a44814111d821fea..555d810cbf872d969bee45796b8717edec75db5d 100644 (file)
@@ -624,6 +624,13 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
 #define Py_XINCREF(op) if ((op) == NULL) ; else Py_INCREF(op)
 #define Py_XDECREF(op) if ((op) == NULL) ; else Py_DECREF(op)
 
+/*
+These are provided as conveniences to Python runtime embedders, so that
+they can have object code that is not dependent on Python compilation flags.
+*/
+PyAPI_FUNC(void) Py_IncRef(PyObject *);
+PyAPI_FUNC(void) Py_DecRef(PyObject *);
+
 /*
 _Py_NoneStruct is an object of undefined type which can be used in contexts
 where NULL (nil) is not suitable (since NULL often means 'error').
index b7133165031869eb48a974422229dde07b24a3e5..70e37d7f4351de7cac8f6cfc079cb67148ce9cea 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -471,6 +471,10 @@ Build
 C API
 -----
 
+- New public functions Py_IncRef() and Py_DecRef(), exposing the
+  functionality of the Py_XINCREF() and Py_XDECREF macros. Useful for
+  runtime dynamic embedding of Python.
+
 - Added a new macro, PySequence_Fast_ITEMS, which retrieves a fast sequence's
   underlying array of PyObject pointers.  Useful for high speed looping.
 
index ba9a1d93b119a9f43ebd98634b49fa7d100e8268..22196d714fe7842097491cdb3fea6d5a2db00e86 100644 (file)
@@ -146,6 +146,18 @@ _Py_NegativeRefcount(const char *fname, int lineno, PyObject *op)
 
 #endif /* Py_REF_DEBUG */
 
+void
+Py_IncRef(PyObject *o)
+{
+    Py_XINCREF(o);
+}
+
+void
+Py_DecRef(PyObject *o)
+{
+    Py_XDECREF(o);
+}
+
 PyObject *
 PyObject_Init(PyObject *op, PyTypeObject *tp)
 {