@@ -27,31 +27,34 @@ 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
3232 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
33+ Python type object *typeobj * (``PyTypeObject* ``).
34+ Fields not defined by the Python object header
3435 are not initialized; the object' s reference count will be one. The size of
3536 the memory allocation is determined from the :c:member:`~PyTypeObject.tp_basicsize` field of
3637 the type object.
3738
3839
39- .. c :function :: TYPE * PyObject_NewVar (TYPE, PyTypeObject * type, Py_ssize_t size)
40+ .. c:macro :: PyObject_NewVar(TYPE, typeobj, size)
4041
4142 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
43+ Python type object *typeobj* (``PyTypeObject*``).
44+ Fields not defined by the Python object header
4345 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
46+ plus *size* (``Py_ssize_t``) fields of the size
47+ given by the :c:member:`~PyTypeObject.tp_itemsize` field of
48+ *typeobj*. This is useful for implementing objects like tuples, which are
4649 able to determine their size at construction time. Embedding the array of
4750 fields into the same allocation decreases the number of allocations,
4851 improving the memory management efficiency.
4952
5053
5154.. c:function:: void PyObject_Del(void *op)
5255
53- Releases memory allocated to an object using :c:func : `PyObject_New ` or
54- :c:func : `PyObject_NewVar `. This is normally called from the
56+ Releases memory allocated to an object using :c:macro :`PyObject_New` or
57+ :c:macro :`PyObject_NewVar`. This is normally called from the
5558 :c:member:`~PyTypeObject.tp_dealloc` handler specified in the object' s type. The fields of
5659 the object should not be accessed after this call as the memory is no
5760 longer a valid Python object.
0 commit comments