On this page
marshal.dump
Up: marshal | Next: marshal.dumps
Rel: marshal.dumps, marshal.load, marshal.loads
Ref: docs.python.org — marshal.dump
Tags: #public #python3 #stdlib #marshal
Import
import marshal
from marshal import dump
Signature & Overview
marshal.dump(value, file, version=5, /, *, allow_code=True)
Write the value on the open file.
Usage
import io
import marshal
buf = io.BytesIO()
marshal.dump([1, "two", (3, 4)], buf)
buf.seek(0)
assert marshal.load(buf) == [1, "two", (3, 4)]
Gotchas
- Internal CPython bytecode serializer only: Format changes across Python versions—never use for application persistence.
REPL Inspect
from marshal import dump
help(dump)
Linked from
Related notes
- tuts/python3/stdlib_module/marshal/dumps Linked here; links to this page; shared tags: #marshal, #stdlib
- tuts/python3/stdlib_module/marshal/load Linked here; links to this page; shared tags: #marshal, #stdlib
- tuts/python3/stdlib_module/marshal/loads Linked here; links to this page; shared tags: #marshal, #stdlib
- tuts/python3/stdlib_module/marshal Linked here; links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib