DAGDA SEARCH | Back to results | Support

Pickle buffer objects — Python 3.16.0a2 documentation

Source: https://docs.python.org/dev/c-api/picklebuffer.html

Navigation

Pickle buffer objects

Added in version 3.8.

A pickle.PickleBuffer object wraps a buffer-providing object for out-of-band data transfer with the pickle module.

PyTypeObject PyPickleBuffer_Type

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

int PyPickleBuffer_Check(PyObject *op)

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

PyObject *PyPickleBuffer_FromObject(PyObject *obj)

Create a pickle buffer from the object obj.

This function will fail if obj doesn’t support the buffer protocol.

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

Analogous to calling pickle.PickleBuffer with obj in Python.

const Py_buffer *PyPickleBuffer_GetBuffer(PyObject *picklebuf)

Get a pointer to the underlying 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 Py_buffer. If the pickle buffer has been released, raise ValueError.

On success, return a pointer to the buffer view. On failure, set an exception and return NULL.

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 pickle.PickleBuffer.release() in Python.

Previous topic

MemoryView objects

Next topic

Weak Reference Objects

This page

«

Navigation

© Copyright 2001 Python Software Foundation.
This page is licensed under the Python Software Foundation License Version 2.
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
See History and License for more information.

The Python Software Foundation is a non-profit corporation. Please donate.

Last updated on Nov 29, 2026 (04:54 UTC). Found a bug?
Created using Sphinx 9.1.1.