Skip to content

Latest commit

 

History

History
59 lines (33 loc) · 1.81 KB

File metadata and controls

59 lines (33 loc) · 1.81 KB
.. index::
   pair: object; PickleBuffer

PickleBuffer objects

.. 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 PickleBuffer 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 PickleBuffer instance.
   This function always succeeds.
.. c:function:: PyObject *PyPickleBuffer_FromObject(PyObject *obj)

   Create a PickleBuffer from the object *obj*.
   *obj* must support the :ref:`buffer protocol <bufferobjects>`.

   On success, return a new PickleBuffer 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 PickleBuffer wraps.
   *picklebuf* must be a PickleBuffer instance.

   On success, return a pointer to the buffer view.
   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 failure, set an exception and return ``NULL``.
   If the PickleBuffer has been released, raise :exc:`ValueError`.
.. c:function:: int PyPickleBuffer_Release(PyObject *picklebuf)

   Release the underlying buffer held by the PickleBuffer.

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

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