Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-75459: Doc: C API: Improve object life cycle documentation#125962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
bc32398
361eaca
b27bcca
b42b58d
7e571ae
97dc30c
85e535a
ef979e6
f3863c4
6a114f9
182c977
7cd0cb5
e34e224
16a29ab
018a3c4
442b7f2
5ed484a
b7774ae
bb1a94f
fd38fd4
3573c79
2633594
c57574a
878fd27
1b96fad
e8c6852
3408919
b6023a3
da3593c
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -22,16 +22,19 @@ Allocating Objects on the Heap | ||
.. warning:: | ||
ZeroIntensity marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
This function does not guarantee that the memory will be completely | ||
zeroed before it is initialized. | ||
.. c:function:: PyVarObject* PyObject_InitVar(PyVarObject *op, PyTypeObject *type, Py_ssize_t size) | ||
This does everything :c:func:`PyObject_Init` does, and also initializes the | ||
length information for a variable-size object. | ||
.. warning:: | ||
ZeroIntensity marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
This function does not guarantee that the memory will be completely | ||
zeroed before it is initialized. | ||
rhansen marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
.. c:macro:: PyObject_New(TYPE, typeobj) | ||
@@ -43,9 +46,9 @@ Allocating Objects on the Heap | ||
allocation is determined from the :c:member:`~PyTypeObject.tp_basicsize` | ||
field of the type object. | ||
When populating a type's :c:member:`~PyTypeObject.tp_alloc` slot, | ||
:c:func:`PyType_GenericAlloc` is preferred over a custom function that | ||
simply calls this macro. | ||
This macro does not call :c:member:`~PyTypeObject.tp_alloc`, | ||
:c:member:`~PyTypeObject.tp_new` (:meth:`~object.__new__`), or | ||
@@ -55,15 +58,13 @@ Allocating Objects on the Heap | ||
set in :c:member:`~PyTypeObject.tp_flags`; use :c:macro:`PyObject_GC_New` | ||
instead. | ||
Memory allocated by this function must be freed with :c:func:`PyObject_Free` | ||
ZeroIntensity marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
(usually called via the object's:c:member:`~PyTypeObject.tp_free` slot). | ||
.. warning:: | ||
ZeroIntensity marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
The returned memory is not guaranteed to have been completely zeroed | ||
before it was initialized. | ||
.. warning:: | ||
ZeroIntensity marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
@@ -93,8 +94,22 @@ Allocating Objects on the Heap | ||
in :c:member:`~PyTypeObject.tp_flags`; use :c:macro:`PyObject_GC_NewVar` | ||
instead. | ||
Memory allocated by this function must be freed with :c:func:`PyObject_Free` | ||
(usually called via the object's :c:member:`~PyTypeObject.tp_free` slot). | ||
.. warning:: | ||
ZeroIntensity marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
The returned memory is not guaranteed to have been completely zeroed | ||
before it was initialized. | ||
.. warning:: | ||
ZeroIntensity marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
This macro does not construct a fully initialized object of the given | ||
type; it merely allocates memory and prepares it for further | ||
initialization by :c:member:`~PyTypeObject.tp_init`. To construct a | ||
fully initialized object, call *typeobj* instead. For example:: | ||
PyObject *foo = PyObject_CallNoArgs((PyObject *)&PyFoo_Type); | ||
ZeroIntensity marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
.. c:function:: void PyObject_Del(void *op) | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -58,15 +58,17 @@ rules: | ||
:c:macro:`Py_TPFLAGS_HAVE_GC` flag set. | ||
Memory allocated by this function must be freed with | ||
ZeroIntensity marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
:c:func:`PyObject_GC_Del` (usually called via the object's | ||
:c:member:`~PyTypeObject.tp_free` slot). | ||
.. c:macro:: PyObject_GC_NewVar(TYPE, typeobj, size) | ||
Analogous to :c:macro:`PyObject_NewVar` but for container objects with the | ||
:c:macro:`Py_TPFLAGS_HAVE_GC` flag set. | ||
Memory allocated by this function must be freed with | ||
ZeroIntensity marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
:c:func:`PyObject_GC_Del` (usually called via the object's | ||
:c:member:`~PyTypeObject.tp_free` slot). | ||
.. c:function:: PyObject* PyUnstable_Object_GC_NewWithExtraData(PyTypeObject *type, size_t extra_size) | ||
@@ -80,7 +82,8 @@ rules: | ||
not managed by Python. | ||
Memory allocated by this function must be freed with | ||
:c:func:`PyObject_GC_Del` (usually called via the object's | ||
:c:member:`~PyTypeObject.tp_free` slot). | ||
.. warning:: | ||
The function is marked as unstable because the final mechanism | ||
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.