Skip to content

Commit 7f68a90

Browse files
Commit
1 parent b2b68d4 commit 7f68a90

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

Doc/c-api/concrete.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Other Objects
109109
descriptor.rst
110110
slice.rst
111111
memoryview.rst
112+
picklebuffer.rst
112113
weakref.rst
113114
capsule.rst
114115
frame.rst

Doc/c-api/picklebuffer.rst

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
.. highlight:: c
2+
3+
.. _picklebuffer-objects:
4+
5+
.. index::
6+
pair: object; PickleBuffer
7+
8+
PickleBuffer objects
9+
--------------------
10+
11+
.. versionadded:: 3.8
12+
13+
A :class:`pickle.PickleBuffer` object wraps a :ref:`buffer-providing object
14+
<bufferobjects>` for out-of-band data transfer with the :mod:`pickle` module.
15+
16+
17+
.. c:var:: PyTypeObject PyPickleBuffer_Type
18+
19+
This instance of :c:type:`PyTypeObject` represents the Python PickleBuffer type.
20+
This is the same object as :class:`pickle.PickleBuffer` in the Python layer.
21+
22+
23+
.. c:function:: int PyPickleBuffer_Check(PyObject *op)
24+
25+
Return true if *op* is a PickleBuffer instance.
26+
This function always succeeds.
27+
28+
29+
.. c:function:: PyObject *PyPickleBuffer_FromObject(PyObject *obj)
30+
31+
Create a PickleBuffer from the object *obj*.
32+
*obj* must support the :ref:`buffer protocol <bufferobjects>`.
33+
34+
On success, return a new PickleBuffer instance.
35+
On failure, set an exception and return ``NULL``.
36+
37+
Analogous to calling :class:`pickle.PickleBuffer` with *obj* in Python.
38+
39+
40+
.. c:function:: const Py_buffer *PyPickleBuffer_GetBuffer(PyObject *picklebuf)
41+
42+
Get a pointer to the underlying :c:type:`Py_buffer` that the PickleBuffer wraps.
43+
*picklebuf* must be a PickleBuffer instance.
44+
45+
On success, return a pointer to the buffer view.
46+
The returned pointer is valid as long as *picklebuf* is alive and has not been
47+
released. The caller must not modify or free the returned :c:type:`Py_buffer`.
48+
49+
On failure, set an exception and return ``NULL``.
50+
If the PickleBuffer has been released, raise :exc:`ValueError`.
51+
52+
53+
.. c:function:: int PyPickleBuffer_Release(PyObject *picklebuf)
54+
55+
Release the underlying buffer held by the PickleBuffer.
56+
57+
Return ``0`` on success. On failure, set an exception and return ``-1``.
58+
59+
Analogous to calling :meth:`pickle.PickleBuffer.release` in Python.

0 commit comments

Comments
 (0)