Movatterモバイル変換


[0]ホーム

URL:


Navigation

Old Buffer Protocol

Deprecated since version 3.0.

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 stillexposed to ease porting 2.x code. They act as a compatibility wrapperaround thenew buffer protocol, but they don’t giveyou control over the lifetime of the resources acquired when a buffer isexported.

Therefore, it is recommended that you callPyObject_GetBuffer()(or they* orw*format codes with thePyArg_ParseTuple() family of functions) to get a buffer view overan object, andPyBuffer_Release() when the buffer view can be released.

intPyObject_AsCharBuffer(PyObject *obj, const char **buffer, Py_ssize_t *buffer_len)

Returns a pointer to a read-only memory location usable as character-basedinput. Theobj argument must support the single-segment character bufferinterface. On success, returns0, setsbuffer to the memory locationandbuffer_len to the buffer length. Returns-1 and sets aTypeError on error.

intPyObject_AsReadBuffer(PyObject *obj, const void **buffer, Py_ssize_t *buffer_len)

Returns a pointer to a read-only memory location containing arbitrary data.Theobj argument must support the single-segment readable bufferinterface. On success, returns0, setsbuffer to the memory locationandbuffer_len to the buffer length. Returns-1 and sets aTypeError on error.

intPyObject_CheckReadBuffer(PyObject *o)

Returns1 ifo supports the single-segment readable buffer interface.Otherwise returns0.

intPyObject_AsWriteBuffer(PyObject *obj, void **buffer, Py_ssize_t *buffer_len)

Returns a pointer to a writable memory location. Theobj argument mustsupport the single-segment, character buffer interface. On success,returns0, setsbuffer to the memory location andbuffer_len to thebuffer length. Returns-1 and sets aTypeError on error.

Previous topic

Buffer Protocol

Next topic

Concrete Objects Layer

This Page

Quick search

Enter search terms or a module, class or function name.

Navigation

©Copyright 1990-2017, Python Software Foundation.
The Python Software Foundation is a non-profit corporation.Please donate.
Last updated on Sep 19, 2017.Found a bug?
Created usingSphinx 1.2.

[8]ページ先頭

©2009-2025 Movatter.jp