summaryrefslogtreecommitdiff
path: root/devdocs/python~3.12/c-api%2Fallocation.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/python~3.12/c-api%2Fallocation.html')
-rw-r--r--devdocs/python~3.12/c-api%2Fallocation.html32
1 files changed, 32 insertions, 0 deletions
diff --git a/devdocs/python~3.12/c-api%2Fallocation.html b/devdocs/python~3.12/c-api%2Fallocation.html
new file mode 100644
index 00000000..34e57881
--- /dev/null
+++ b/devdocs/python~3.12/c-api%2Fallocation.html
@@ -0,0 +1,32 @@
+ <span id="allocating-objects"></span><h1>Allocating Objects on the Heap</h1> <dl class="c function"> <dt class="sig sig-object c" id="c._PyObject_New">
+<code>PyObject *_PyObject_New(PyTypeObject *type)</code> </dt> <dd><em class="refcount">Return value: New reference.</em></dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c._PyObject_NewVar">
+<code>PyVarObject *_PyObject_NewVar(PyTypeObject *type, Py_ssize_t size)</code> </dt> <dd><em class="refcount">Return value: New reference.</em></dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyObject_Init">
+<code>PyObject *PyObject_Init(PyObject *op, PyTypeObject *type)</code> </dt> <dd>
+<em class="refcount">Return value: Borrowed reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Initialize a newly allocated object <em>op</em> with its type and initial reference. Returns the initialized object. If <em>type</em> indicates that the object participates in the cyclic garbage detector, it is added to the detector’s set of observed objects. Other fields of the object are not affected.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyObject_InitVar">
+<code>PyVarObject *PyObject_InitVar(PyVarObject *op, PyTypeObject *type, Py_ssize_t size)</code> </dt> <dd>
+<em class="refcount">Return value: Borrowed reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>This does everything <a class="reference internal" href="#c.PyObject_Init" title="PyObject_Init"><code>PyObject_Init()</code></a> does, and also initializes the length information for a variable-size object.</p> </dd>
+</dl> <dl class="c macro"> <dt class="sig sig-object c" id="c.PyObject_New">
+<code>PyObject_New(TYPE, typeobj)</code> </dt> <dd>
+<p>Allocate a new Python object using the C structure type <em>TYPE</em> and the Python type object <em>typeobj</em> (<code>PyTypeObject*</code>). Fields not defined by the Python object header are not initialized. The caller will own the only reference to the object (i.e. its reference count will be one). The size of the memory allocation is determined from the <a class="reference internal" href="typeobj#c.PyTypeObject.tp_basicsize" title="PyTypeObject.tp_basicsize"><code>tp_basicsize</code></a> field of the type object.</p> </dd>
+</dl> <dl class="c macro"> <dt class="sig sig-object c" id="c.PyObject_NewVar">
+<code>PyObject_NewVar(TYPE, typeobj, size)</code> </dt> <dd>
+<p>Allocate a new Python object using the C structure type <em>TYPE</em> and the Python type object <em>typeobj</em> (<code>PyTypeObject*</code>). Fields not defined by the Python object header are not initialized. The allocated memory allows for the <em>TYPE</em> structure plus <em>size</em> (<code>Py_ssize_t</code>) fields of the size given by the <a class="reference internal" href="typeobj#c.PyTypeObject.tp_itemsize" title="PyTypeObject.tp_itemsize"><code>tp_itemsize</code></a> field of <em>typeobj</em>. This is useful for implementing objects like tuples, which are able to determine their size at construction time. Embedding the array of fields into the same allocation decreases the number of allocations, improving the memory management efficiency.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyObject_Del">
+<code>void PyObject_Del(void *op)</code> </dt> <dd>
+<p>Releases memory allocated to an object using <a class="reference internal" href="#c.PyObject_New" title="PyObject_New"><code>PyObject_New</code></a> or <a class="reference internal" href="#c.PyObject_NewVar" title="PyObject_NewVar"><code>PyObject_NewVar</code></a>. This is normally called from the <a class="reference internal" href="typeobj#c.PyTypeObject.tp_dealloc" title="PyTypeObject.tp_dealloc"><code>tp_dealloc</code></a> handler specified in the object’s type. The fields of the object should not be accessed after this call as the memory is no longer a valid Python object.</p> </dd>
+</dl> <dl class="c var"> <dt class="sig sig-object c" id="c._Py_NoneStruct">
+<code>PyObject _Py_NoneStruct</code> </dt> <dd>
+<p>Object which is visible in Python as <code>None</code>. This should only be accessed using the <a class="reference internal" href="none#c.Py_None" title="Py_None"><code>Py_None</code></a> macro, which evaluates to a pointer to this object.</p> </dd>
+</dl> <div class="admonition seealso"> <p class="admonition-title">See also</p> <dl class="simple"> <dt>
+<code></code> <a class="reference internal" href="module#c.PyModule_Create" title="PyModule_Create"><code>PyModule_Create()</code></a>
+</dt>
+<dd>
+<p>To allocate and create extension modules.</p> </dd> </dl> </div> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; 2001&ndash;2023 Python Software Foundation<br>Licensed under the PSF License.<br>
+ <a href="https://docs.python.org/3.12/c-api/allocation.html" class="_attribution-link">https://docs.python.org/3.12/c-api/allocation.html</a>
+ </p>
+</div>