equal
deleted
inserted
replaced
|
1 .. highlightlang:: c |
|
2 |
|
3 .. _abstract-buffer: |
|
4 |
|
5 Buffer Protocol |
|
6 =============== |
|
7 |
|
8 |
|
9 .. cfunction:: int PyObject_AsCharBuffer(PyObject *obj, const char **buffer, Py_ssize_t *buffer_len) |
|
10 |
|
11 Returns a pointer to a read-only memory location usable as character-based |
|
12 input. The *obj* argument must support the single-segment character buffer |
|
13 interface. On success, returns ``0``, sets *buffer* to the memory location and |
|
14 *buffer_len* to the buffer length. Returns ``-1`` and sets a :exc:`TypeError` |
|
15 on error. |
|
16 |
|
17 .. versionadded:: 1.6 |
|
18 |
|
19 |
|
20 .. cfunction:: int PyObject_AsReadBuffer(PyObject *obj, const void **buffer, Py_ssize_t *buffer_len) |
|
21 |
|
22 Returns a pointer to a read-only memory location containing arbitrary data. The |
|
23 *obj* argument must support the single-segment readable buffer interface. On |
|
24 success, returns ``0``, sets *buffer* to the memory location and *buffer_len* to |
|
25 the buffer length. Returns ``-1`` and sets a :exc:`TypeError` on error. |
|
26 |
|
27 .. versionadded:: 1.6 |
|
28 |
|
29 |
|
30 .. cfunction:: int PyObject_CheckReadBuffer(PyObject *o) |
|
31 |
|
32 Returns ``1`` if *o* supports the single-segment readable buffer interface. |
|
33 Otherwise returns ``0``. |
|
34 |
|
35 .. versionadded:: 2.2 |
|
36 |
|
37 |
|
38 .. cfunction:: int PyObject_AsWriteBuffer(PyObject *obj, void **buffer, Py_ssize_t *buffer_len) |
|
39 |
|
40 Returns a pointer to a writeable memory location. The *obj* argument must |
|
41 support the single-segment, character buffer interface. On success, returns |
|
42 ``0``, sets *buffer* to the memory location and *buffer_len* to the buffer |
|
43 length. Returns ``-1`` and sets a :exc:`TypeError` on error. |
|
44 |
|
45 .. versionadded:: 1.6 |
|
46 |