1
from libc.stdio cimport FILE
3
cdef extern from "Python.h":
5
###########################################################################
6
# Data marshalling support
7
###########################################################################
9
const int Py_MARSHAL_VERSION
11
void PyMarshal_WriteLongToFile(long value, FILE *file, int version)
12
# Marshal a long integer, value, to file. This will only write the
13
# least-significant 32 bits of value, regardless of the size of the native
14
# long type. version indicates the file format.
16
void PyMarshal_WriteObjectToFile(object value, FILE *file, int version)
17
# Marshal a Python object, value, to file. version indicates the file
20
bytes PyMarshal_WriteObjectToString(object value, int version)
21
# Return value: New reference.
22
# Return a bytes object containing the marshalled representation of value.
23
# version indicates the file format.
25
long PyMarshal_ReadLongFromFile(FILE *file) except? -1
26
# Return a C long from the data stream in a FILE* opened for reading. Only
27
# a 32-bit value can be read in using this function, regardless of the
28
# native size of long.
30
# On error, sets the appropriate exception (EOFError) and returns -1.
32
int PyMarshal_ReadShortFromFile(FILE *file) except? -1
33
# Return a C short from the data stream in a FILE* opened for reading. Only
34
# a 16-bit value can be read in using this function, regardless of the
35
# native size of short.
37
# On error, sets the appropriate exception (EOFError) and returns -1.
39
object PyMarshal_ReadObjectFromFile(FILE *file)
40
# Return value: New reference.
41
# Return a Python object from the data stream in a FILE* opened for
44
# On error, sets the appropriate exception (EOFError, ValueError or
45
# TypeError) and returns NULL.
47
object PyMarshal_ReadLastObjectFromFile(FILE *file)
48
# Return value: New reference.
49
# Return a Python object from the data stream in a FILE* opened for
50
# reading. Unlike PyMarshal_ReadObjectFromFile(), this function assumes
51
# that no further objects will be read from the file, allowing it to
52
# aggressively load file data into memory so that the de-serialization can
53
# operate from data in memory, rather than reading a byte at a time from the
54
# file. Only use these variant if you are certain that you won’t be reading
55
# anything else from the file.
57
# On error, sets the appropriate exception (EOFError, ValueError or
58
# TypeError) and returns NULL.
60
object PyMarshal_ReadObjectFromString(const char *data, Py_ssize_t len)
61
# Return value: New reference.
62
# Return a Python object from the data stream in a byte buffer containing
63
# len bytes pointed to by data.
65
# On error, sets the appropriate exception (EOFError, ValueError or
66
# TypeError) and returns NULL.