Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Doc/c-api/concrete.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Other Objects
descriptor.rst
slice.rst
memoryview.rst
picklebuffer.rst
weakref.rst
capsule.rst
frame.rst
Expand Down
58 changes: 58 additions & 0 deletions Doc/c-api/picklebuffer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.. highlight:: c

.. _picklebuffer-objects:

.. index::
pair: object; PickleBuffer

PickleBuffer objects
--------------------
Comment thread
StanFromIreland marked this conversation as resolved.
Outdated

.. versionadded:: 3.8

A :class:`pickle.PickleBuffer` object wraps a :ref:`buffer-providing object
<bufferobjects>` for out-of-band data transfer with the :mod:`pickle` module.


.. c:var:: PyTypeObject PyPickleBuffer_Type

This instance of :c:type:`PyTypeObject` represents the Python pickle buffer type.
This is the same object as :class:`pickle.PickleBuffer` in the Python layer.


.. c:function:: int PyPickleBuffer_Check(PyObject *op)

Return true if *op* is a pickle buffer instance.
This function always succeeds.


.. c:function:: PyObject *PyPickleBuffer_FromObject(PyObject *obj)

Create a pickle buffer from the object *obj*.
This function will fail if *obj* doesn't support the :ref:`buffer protocol <bufferobjects>`.
Comment thread
StanFromIreland marked this conversation as resolved.

On success, return a new pickle buffer instance.
On failure, set an exception and return ``NULL``.

Analogous to calling :class:`pickle.PickleBuffer` with *obj* in Python.


.. c:function:: const Py_buffer *PyPickleBuffer_GetBuffer(PyObject *picklebuf)

Get a pointer to the underlying :c:type:`Py_buffer` that the pickle buffer wraps.

The returned pointer is valid as long as *picklebuf* is alive and has not been
released. The caller must not modify or free the returned :c:type:`Py_buffer`.

On success, return a pointer to the buffer view.
On failure, set an exception and return ``NULL``.
If the pickle buffer has been released, raise :exc:`ValueError`.
Comment thread
StanFromIreland marked this conversation as resolved.
Outdated


.. c:function:: int PyPickleBuffer_Release(PyObject *picklebuf)

Release the underlying buffer held by the pickle buffer.

Return ``0`` on success. On failure, set an exception and return ``-1``.

Analogous to calling :meth:`pickle.PickleBuffer.release` in Python.
Loading