@@ -27,31 +27,35 @@ Allocating Objects on the Heap
2727 length information for a variable-size object.
2828
2929
30- .. c :function :: TYPE * PyObject_New (TYPE, PyTypeObject * type )
30+ .. c :macro :: PyObject_New(TYPE , typeobj )
3131
32- Allocate a new Python object using the C structure type *TYPE * and the
33- Python type object *type *. Fields not defined by the Python object header
34- are not initialized; the object's reference count will be one. The size of
35- the memory allocation is determined from the :c:member: `~PyTypeObject.tp_basicsize ` field of
36- the type object.
32+ Allocate a new Python object using the C structure type *TYPE *
33+ and the Python type object *typeobj * (``PyTypeObject* ``).
34+ Fields not defined by the Python object header are not initialized.
35+ The caller will own the only reference to the object
36+ (i.e. its reference count will be one).
37+ The size of the memory allocation is determined from the
38+ :c:member:`~PyTypeObject.tp_basicsize` field of the type object.
3739
3840
39- .. c :function :: TYPE * PyObject_NewVar (TYPE, PyTypeObject * type, Py_ssize_t size)
41+ .. c:macro :: PyObject_NewVar(TYPE, typeobj, size)
4042
4143 Allocate a new Python object using the C structure type *TYPE* and the
42- Python type object *type *. Fields not defined by the Python object header
44+ Python type object *typeobj* (``PyTypeObject* ``).
45+ Fields not defined by the Python object header
4346 are not initialized. The allocated memory allows for the *TYPE* structure
44- plus *size * fields of the size given by the :c:member: `~PyTypeObject.tp_itemsize ` field of
45- *type *. This is useful for implementing objects like tuples, which are
47+ plus *size* (``Py_ssize_t ``) fields of the size
48+ given by the :c:member:`~PyTypeObject.tp_itemsize` field of
49+ *typeobj*. This is useful for implementing objects like tuples, which are
4650 able to determine their size at construction time. Embedding the array of
4751 fields into the same allocation decreases the number of allocations,
4852 improving the memory management efficiency.
4953
5054
5155.. c:function:: void PyObject_Del(void *op)
5256
53- Releases memory allocated to an object using :c:func : `PyObject_New ` or
54- :c:func : `PyObject_NewVar `. This is normally called from the
57+ Releases memory allocated to an object using :c:macro : `PyObject_New ` or
58+ :c:macro : `PyObject_NewVar `. This is normally called from the
5559 :c:member: `~PyTypeObject.tp_dealloc ` handler specified in the object's type. The fields of
5660 the object should not be accessed after this call as the memory is no
5761 longer a valid Python object.
0 commit comments