summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/allocation.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/c-api/allocation.rst')
-rw-r--r--Doc/c-api/allocation.rst69
1 files changed, 60 insertions, 9 deletions
diff --git a/Doc/c-api/allocation.rst b/Doc/c-api/allocation.rst
index 33b0c06..7f7435f 100644
--- a/Doc/c-api/allocation.rst
+++ b/Doc/c-api/allocation.rst
@@ -1,4 +1,4 @@
-.. highlight:: c
+.. highlightlang:: c
.. _allocating-objects:
@@ -11,6 +11,13 @@ Allocating Objects on the Heap
.. c:function:: PyVarObject* _PyObject_NewVar(PyTypeObject *type, Py_ssize_t size)
+ .. versionchanged:: 2.5
+ This function used an :c:type:`int` type for *size*. This might require
+ changes in your code for properly supporting 64-bit systems.
+
+
+.. c:function:: void _PyObject_Del(PyObject *op)
+
.. c:function:: PyObject* PyObject_Init(PyObject *op, PyTypeObject *type)
@@ -26,6 +33,10 @@ Allocating Objects on the Heap
This does everything :c:func:`PyObject_Init` does, and also initializes the
length information for a variable-size object.
+ .. versionchanged:: 2.5
+ This function used an :c:type:`int` type for *size*. This might require
+ changes in your code for properly supporting 64-bit systems.
+
.. c:function:: TYPE* PyObject_New(TYPE, PyTypeObject *type)
@@ -47,8 +58,12 @@ Allocating Objects on the Heap
fields into the same allocation decreases the number of allocations,
improving the memory management efficiency.
+ .. versionchanged:: 2.5
+ This function used an :c:type:`int` type for *size*. This might require
+ changes in your code for properly supporting 64-bit systems.
+
-.. c:function:: void PyObject_Del(void *op)
+.. c:function:: void PyObject_Del(PyObject *op)
Releases memory allocated to an object using :c:func:`PyObject_New` or
:c:func:`PyObject_NewVar`. This is normally called from the
@@ -57,15 +72,51 @@ Allocating Objects on the Heap
longer a valid Python object.
-.. c:var:: PyObject _Py_NoneStruct
+.. c:function:: PyObject* Py_InitModule(char *name, PyMethodDef *methods)
- Object which is visible in Python as ``None``. This should only be accessed
- using the :c:macro:`Py_None` macro, which evaluates to a pointer to this
- object.
+ Create a new module object based on a name and table of functions,
+ returning the new module object.
+
+ .. versionchanged:: 2.3
+ Older versions of Python did not support *NULL* as the value for the
+ *methods* argument.
+
+
+.. c:function:: PyObject* Py_InitModule3(char *name, PyMethodDef *methods, char *doc)
+ Create a new module object based on a name and table of functions,
+ returning the new module object. If *doc* is non-*NULL*, it will be used
+ to define the docstring for the module.
-.. seealso::
+ .. versionchanged:: 2.3
+ Older versions of Python did not support *NULL* as the value for the
+ *methods* argument.
- :c:func:`PyModule_Create`
- To allocate and create extension modules.
+.. c:function:: PyObject* Py_InitModule4(char *name, PyMethodDef *methods, char *doc, PyObject *self, int apiver)
+
+ Create a new module object based on a name and table of functions,
+ returning the new module object. If *doc* is non-*NULL*, it will be used
+ to define the docstring for the module. If *self* is non-*NULL*, it will
+ be passed to the functions of the module as their (otherwise *NULL*) first
+ parameter. (This was added as an experimental feature, and there are no
+ known uses in the current version of Python.) For *apiver*, the only value
+ which should be passed is defined by the constant
+ :const:`PYTHON_API_VERSION`.
+
+ .. note::
+
+ Most uses of this function should probably be using the
+ :c:func:`Py_InitModule3` instead; only use this if you are sure you need
+ it.
+
+ .. versionchanged:: 2.3
+ Older versions of Python did not support *NULL* as the value for the
+ *methods* argument.
+
+
+.. c:var:: PyObject _Py_NoneStruct
+
+ Object which is visible in Python as ``None``. This should only be
+ accessed using the ``Py_None`` macro, which evaluates to a pointer to this
+ object.