Teks sumber — English
Terjemahan — Bahasa Indonesia
This is not a general "persistence" module. For general persistence and transfer of Python objects through RPC calls, see the modules :mod:`pickle` and :mod:`shelve`. The :mod:`!marshal` module exists mainly to support reading and writing the "pseudo-compiled" code for Python modules of :file:`.pyc` files. Therefore, the Python maintainers reserve the right to modify the marshal format in backward incompatible ways should the need arise. The format of code objects is not compatible between Python versions, even if the version of the format is the same. De-serializing a code object in the incorrect Python version has undefined behavior. If you're serializing and de-serializing Python objects, use the :mod:`pickle` module instead -- the performance is comparable, version independence is guaranteed, and pickle supports a substantially wider range of objects than marshal.
If the value has (or contains an object that has) an unsupported type, a :exc:`ValueError` exception is raised --- but garbage data will also be written to the file. The object will not be properly read back by :func:`load`. :ref:`Code objects <code-objects>` are only supported if *allow_code* is true.
Read one value from the open file and return it. If no valid value is read (e.g. because the data has a different Python version's incompatible marshal format), raise :exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`. :ref:`Code objects <code-objects>` are only supported if *allow_code* is true. The file must be a readable :term:`binary file`.
This call used to raise a ``code.__new__`` audit event for each code object. Now it raises a single ``marshal.load`` event for the entire load operation.
Return the bytes object that would be written to a file by ``dump(value, file)``. The value must be a supported type. Raise a :exc:`ValueError` exception if value has (or contains an object that has) an unsupported type. :ref:`Code objects <code-objects>` are only supported if *allow_code* is true.
Convert the :term:`bytes-like object` to a value. If no valid value is found, raise :exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`. :ref:`Code objects <code-objects>` are only supported if *allow_code* is true. Extra bytes in the input are ignored.
This call used to raise a ``code.__new__`` audit event for each code object. Now it raises a single ``marshal.loads`` event for the entire load operation.
code object
objek kode