@@ -26,17 +26,19 @@ characteristic of being backed by a possibly large memory buffer. It is
26
26
then desirable, in some situations, to access that buffer directly and
27
27
without intermediate copying.
28
28
29
- Python provides such a facility at the C level in the form of the :ref: ` buffer
30
- protocol <bufferobjects>`. This protocol has two sides:
29
+ Python provides such a facility at the C and Python level in the form of the
30
+ :ref: ` buffer protocol <bufferobjects >`. This protocol has two sides:
31
31
32
32
.. index :: single: PyBufferProcs (C type)
33
33
34
34
- on the producer side, a type can export a "buffer interface" which allows
35
35
objects of that type to expose information about their underlying buffer.
36
- This interface is described in the section :ref: `buffer-structs `;
36
+ This interface is described in the section :ref: `buffer-structs `; for
37
+ Python see :ref: `python-buffer-protocol `.
37
38
38
39
- on the consumer side, several means are available to obtain a pointer to
39
- the raw underlying data of an object (for example a method parameter).
40
+ the raw underlying data of an object (for example a method parameter). For
41
+ Python see :class: `memoryview `.
40
42
41
43
Simple objects such as :class: `bytes ` and :class: `bytearray ` expose their
42
44
underlying buffer in byte-oriented form. Other forms are possible; for example,
@@ -62,6 +64,10 @@ In both cases, :c:func:`PyBuffer_Release` must be called when the buffer
62
64
isn't needed anymore. Failure to do so could lead to various issues such as
63
65
resource leaks.
64
66
67
+ .. versionadded :: 3.12
68
+
69
+ The buffer protocol is now accessible in Python, see
70
+ :ref: `python-buffer-protocol ` and :class: `memoryview `.
65
71
66
72
.. _buffer-structure :
67
73
0 commit comments