diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/python~3.12/c-api%2Fobjbuffer.html | |
new repository
Diffstat (limited to 'devdocs/python~3.12/c-api%2Fobjbuffer.html')
| -rw-r--r-- | devdocs/python~3.12/c-api%2Fobjbuffer.html | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/devdocs/python~3.12/c-api%2Fobjbuffer.html b/devdocs/python~3.12/c-api%2Fobjbuffer.html new file mode 100644 index 00000000..951bbe2e --- /dev/null +++ b/devdocs/python~3.12/c-api%2Fobjbuffer.html @@ -0,0 +1,18 @@ + <h1>Old Buffer Protocol</h1> <div class="deprecated"> <p><span class="versionmodified deprecated">Deprecated since version 3.0.</span></p> </div> <p>These functions were part of the “old buffer protocol” API in Python 2. In Python 3, this protocol doesn’t exist anymore but the functions are still exposed to ease porting 2.x code. They act as a compatibility wrapper around the <a class="reference internal" href="buffer#bufferobjects"><span class="std std-ref">new buffer protocol</span></a>, but they don’t give you control over the lifetime of the resources acquired when a buffer is exported.</p> <p>Therefore, it is recommended that you call <a class="reference internal" href="buffer#c.PyObject_GetBuffer" title="PyObject_GetBuffer"><code>PyObject_GetBuffer()</code></a> (or the <code>y*</code> or <code>w*</code> <a class="reference internal" href="arg#arg-parsing"><span class="std std-ref">format codes</span></a> with the <a class="reference internal" href="arg#c.PyArg_ParseTuple" title="PyArg_ParseTuple"><code>PyArg_ParseTuple()</code></a> family of functions) to get a buffer view over an object, and <a class="reference internal" href="buffer#c.PyBuffer_Release" title="PyBuffer_Release"><code>PyBuffer_Release()</code></a> when the buffer view can be released.</p> <dl class="c function"> <dt class="sig sig-object c" id="c.PyObject_AsCharBuffer"> +<code>int PyObject_AsCharBuffer(PyObject *obj, const char **buffer, Py_ssize_t *buffer_len)</code> </dt> <dd> +<em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Returns a pointer to a read-only memory location usable as character-based input. The <em>obj</em> argument must support the single-segment character buffer interface. On success, returns <code>0</code>, sets <em>buffer</em> to the memory location and <em>buffer_len</em> to the buffer length. Returns <code>-1</code> and sets a <a class="reference internal" href="../library/exceptions#TypeError" title="TypeError"><code>TypeError</code></a> on error.</p> </dd> +</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyObject_AsReadBuffer"> +<code>int PyObject_AsReadBuffer(PyObject *obj, const void **buffer, Py_ssize_t *buffer_len)</code> </dt> <dd> +<em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Returns a pointer to a read-only memory location containing arbitrary data. The <em>obj</em> argument must support the single-segment readable buffer interface. On success, returns <code>0</code>, sets <em>buffer</em> to the memory location and <em>buffer_len</em> to the buffer length. Returns <code>-1</code> and sets a <a class="reference internal" href="../library/exceptions#TypeError" title="TypeError"><code>TypeError</code></a> on error.</p> </dd> +</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyObject_CheckReadBuffer"> +<code>int PyObject_CheckReadBuffer(PyObject *o)</code> </dt> <dd> +<em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Returns <code>1</code> if <em>o</em> supports the single-segment readable buffer interface. Otherwise returns <code>0</code>. This function always succeeds.</p> <p>Note that this function tries to get and release a buffer, and exceptions which occur while calling corresponding functions will get suppressed. To get error reporting use <a class="reference internal" href="buffer#c.PyObject_GetBuffer" title="PyObject_GetBuffer"><code>PyObject_GetBuffer()</code></a> instead.</p> </dd> +</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyObject_AsWriteBuffer"> +<code>int PyObject_AsWriteBuffer(PyObject *obj, void **buffer, Py_ssize_t *buffer_len)</code> </dt> <dd> +<em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Returns a pointer to a writable memory location. The <em>obj</em> argument must support the single-segment, character buffer interface. On success, returns <code>0</code>, sets <em>buffer</em> to the memory location and <em>buffer_len</em> to the buffer length. Returns <code>-1</code> and sets a <a class="reference internal" href="../library/exceptions#TypeError" title="TypeError"><code>TypeError</code></a> on error.</p> </dd> +</dl> <div class="_attribution"> + <p class="_attribution-p"> + © 2001–2023 Python Software Foundation<br>Licensed under the PSF License.<br> + <a href="https://docs.python.org/3.12/c-api/objbuffer.html" class="_attribution-link">https://docs.python.org/3.12/c-api/objbuffer.html</a> + </p> +</div> |
