/usr/share/doc/python3-docs/html/_sources/c-api
NameSizeModeActions
abstract.rst.txt7150644editdlrm
allocation.rst.txt26530644editdlrm
apiabiversion.rst.txt22420644editdlrm
arg.rst.txt306510644editdlrm
bool.rst.txt12000644editdlrm
buffer.rst.txt222670644editdlrm
bytearray.rst.txt22500644editdlrm
bytes.rst.txt92110644editdlrm
capsule.rst.txt57410644editdlrm
cell.rst.txt19400644editdlrm
code.rst.txt16660644editdlrm
codec.rst.txt47990644editdlrm
complex.rst.txt39460644editdlrm
concrete.rst.txt20460644editdlrm
conversion.rst.txt55160644editdlrm
coro.rst.txt8200644editdlrm
datetime.rst.txt64150644editdlrm
descriptor.rst.txt11110644editdlrm
dict.rst.txt79520644editdlrm
exceptions.rst.txt478140644editdlrm
file.rst.txt32480644editdlrm
float.rst.txt22430644editdlrm
function.rst.txt33480644editdlrm
gcsupport.rst.txt60570644editdlrm
gen.rst.txt13010644editdlrm
import.rst.txt128250644editdlrm
index.rst.txt6130644editdlrm
init.rst.txt523830644editdlrm
intro.rst.txt287510644editdlrm
iter.rst.txt11290644editdlrm
iterator.rst.txt16400644editdlrm
list.rst.txt47350644editdlrm
long.rst.txt104360644editdlrm
mapping.rst.txt28710644editdlrm
marshal.rst.txt35610644editdlrm
memory.rst.txt213690644editdlrm
memoryview.rst.txt23480644editdlrm
method.rst.txt28180644editdlrm
module.rst.txt182660644editdlrm
none.rst.txt7400644editdlrm
number.rst.txt105830644editdlrm
objbuffer.rst.txt21980644editdlrm
object.rst.txt174200644editdlrm
objimpl.rst.txt3040644editdlrm
refcounting.rst.txt29090644editdlrm
reflection.rst.txt14170644editdlrm
sequence.rst.txt65470644editdlrm
set.rst.txt61440644editdlrm
slice.rst.txt24040644editdlrm
stable.rst.txt19690644editdlrm
structures.rst.txt137870644editdlrm
sys.rst.txt99440644editdlrm
tuple.rst.txt80310644editdlrm
type.rst.txt39630644editdlrm
typeobj.rst.txt601840644editdlrm
unicode.rst.txt680740644editdlrm
utilities.rst.txt4140644editdlrm
veryhigh.rst.txt166550644editdlrm
weakref.rst.txt26350644editdlrm
Edit: /usr/share/doc/python3-docs/html/_sources/c-api/marshal.rst.txt (3561B)
.. highlightlang:: c .. _marshalling-utils: Data marshalling support ======================== These routines allow C code to work with serialized objects using the same data format as the :mod:`marshal` module. There are functions to write data into the serialization format, and additional functions that can be used to read the data back. Files used to store marshalled data must be opened in binary mode. Numeric values are stored with the least significant byte first. The module supports two versions of the data format: version 0 is the historical version, version 1 shares interned strings in the file, and upon unmarshalling. Version 2 uses a binary format for floating point numbers. *Py_MARSHAL_VERSION* indicates the current file format (currently 2). .. c:function:: void PyMarshal_WriteLongToFile(long value, FILE *file, int version) Marshal a :c:type:`long` integer, *value*, to *file*. This will only write the least-significant 32 bits of *value*; regardless of the size of the native :c:type:`long` type. *version* indicates the file format. .. c:function:: void PyMarshal_WriteObjectToFile(PyObject *value, FILE *file, int version) Marshal a Python object, *value*, to *file*. *version* indicates the file format. .. c:function:: PyObject* PyMarshal_WriteObjectToString(PyObject *value, int version) Return a bytes object containing the marshalled representation of *value*. *version* indicates the file format. The following functions allow marshalled values to be read back in. .. c:function:: long PyMarshal_ReadLongFromFile(FILE *file) Return a C :c:type:`long` from the data stream in a :c:type:`FILE\*` opened for reading. Only a 32-bit value can be read in using this function, regardless of the native size of :c:type:`long`. On error, sets the appropriate exception (:exc:`EOFError`) and returns ``-1``. .. c:function:: int PyMarshal_ReadShortFromFile(FILE *file) Return a C :c:type:`short` from the data stream in a :c:type:`FILE\*` opened for reading. Only a 16-bit value can be read in using this function, regardless of the native size of :c:type:`short`. On error, sets the appropriate exception (:exc:`EOFError`) and returns ``-1``. .. c:function:: PyObject* PyMarshal_ReadObjectFromFile(FILE *file) Return a Python object from the data stream in a :c:type:`FILE\*` opened for reading. On error, sets the appropriate exception (:exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`) and returns *NULL*. .. c:function:: PyObject* PyMarshal_ReadLastObjectFromFile(FILE *file) Return a Python object from the data stream in a :c:type:`FILE\*` opened for reading. Unlike :c:func:`PyMarshal_ReadObjectFromFile`, this function assumes that no further objects will be read from the file, allowing it to aggressively load file data into memory so that the de-serialization can operate from data in memory rather than reading a byte at a time from the file. Only use these variant if you are certain that you won't be reading anything else from the file. On error, sets the appropriate exception (:exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`) and returns *NULL*. .. c:function:: PyObject* PyMarshal_ReadObjectFromString(const char *data, Py_ssize_t len) Return a Python object from the data stream in a byte buffer containing *len* bytes pointed to by *data*. On error, sets the appropriate exception (:exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`) and returns *NULL*.