Persistence and Serialization Modules
marshal
Encodes a limited set of Python values in an internal binary format used for bytecode caches. It is not a stable general-purpose persistence format, especially for code objects across Python versions. Never load untrusted data; Python 3.13 adds allow_code=False to exclude code objects, not to make hostile inputs safe.
Formal Syntax & Structure
python syntaxpython
import marshalReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
import marshaldata = marshal.dumps((2, "tea"), allow_code=False)print(marshal.loads(data, allow_code=False))