"marshal" --- 내부 파이썬 객체 직렬화
*************************************

======================================================================

이 모듈은 바이너리 형식으로 파이썬 값을 읽고 쓸 수 있는 함수를 포함합
니다. 형식은 파이썬에만 국한되지만, 기계 아키텍처 문제에는 독립적입니
다 (예를 들어, 파이썬 값을 PC의 파일에 기록하고 파일을 맥으로 보낸 다
음, 그곳에서 다시 읽을 수 있습니다). 형식의 세부 사항은 의도적으로 설
명하지 않습니다; 파이썬 버전 간에 변경될 수 있습니다 (드물긴 하지만).
[1]

This is not a general "persistence" module.  For general persistence
and transfer of Python objects through RPC calls, see the modules
"pickle" and "shelve".  The "marshal" module exists mainly to support
reading and writing the "pseudo-compiled" code for Python modules of
".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 "pickle" module instead -- the performance is
comparable, version independence is guaranteed, and pickle supports a
substantially wider range of objects than marshal.

경고:

  The "marshal" module is not intended to be secure against erroneous
  or maliciously constructed data.  Never unmarshal data received from
  an untrusted or unauthenticated source.

파일을 읽고 쓰는 함수는 물론 바이트열류 객체에서 작동하는 함수도 있습
니다.

Not all Python object types are supported; in general, only objects
whose value is independent from a particular invocation of Python can
be written and read by this module.  The following types are
supported:

* Numeric types: "int", "bool", "float", "complex".

* Strings ("str") and "bytes". *Bytes-like objects* like "bytearray"
  are marshalled as "bytes".

* Containers: "tuple", "list", "set", "frozenset", and (since
  "version" 5), "slice". It should be understood that these are
  supported only if the values contained therein are themselves
  supported. Recursive containers are supported since "version" 3.

* The singletons "None", "Ellipsis" and "StopIteration".

* "code" objects, if *allow_code* is true. See note above about
  version dependence.

버전 3.4에서 변경:

* Added format version 3, which supports marshalling recursive lists,
  sets and dictionaries.

* Added format version 4, which supports efficient representations of
  short strings.

버전 3.14에서 변경: Added format version 5, which allows marshalling
slices.

모듈은 다음 함수를 정의합니다:

marshal.dump(value, file, version=version, /, *, allow_code=True)

   열린 파일에 값을 기록합니다. value는 지원되는 형이어야 합니다. 파일
   은 쓰기 가능한 *바이너리 파일* 이어야 합니다.

   value가 지원되지 않는 형이면 (또는 지원되지 않는 형의 객체를 담고
   있다면) "ValueError" 예외가 발생합니다 --- 하지만, 찌꺼기 데이터도
   파일에 기록됩니다. "load()"로 객체를 제대로 읽을 수 없습니다. 코드
   객체는 *allow_code*가 참일 때만 지원됩니다.

   *version* 인자는 "dump"가 사용해야 하는 데이터 형식을 나타냅니다 (
   아래를 참조하십시오).

   Raises an auditing event "marshal.dumps" with arguments "value",
   "version".

   버전 3.13에서 변경: Added the *allow_code* parameter.

marshal.load(file, /, *, allow_code=True)

   열린 파일에서 하나의 값을 읽고 그것을 반환합니다. 유효한 값을 읽히
   지 않으면 (예를 들어, 데이터가 다른 파이썬 버전의 호환되지 않는 마
   샬 형식이라서) "EOFError", "ValueError" 또는 "TypeError"를 발생시킵
   니다. 코드 객체는 *allow_code*가 참일 때만 지원됩니다. 파일은 읽을
   수 있는 *바이너리 파일* 이어야 합니다.

   Raises an auditing event "marshal.load" with no arguments.

   참고:

     지원하지 않는 형을 포함하는 객체가 "dump()"로 마샬 되었으면,
     "load()"는 역 마샬이 불가능한 형을 "None"으로 치환합니다.

   버전 3.10에서 변경: 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.

   버전 3.13에서 변경: Added the *allow_code* parameter.

marshal.dumps(value, version=version, /, *, allow_code=True)

   "dump(value, file)"에 의해 파일에 기록될 바이트열 객체를 반환합니다
   . value는 지원되는 형이어야 합니다. value가 지원되지 않는 형이면 (
   또는 지원되지 않는 형의 객체를 담고 있다면) "ValueError" 예외를 발
   생시킵니다. 코드 객체는 *allow_code*가 참일 때만 지원됩니다.

   *version* 인자는 "dumps"가 사용해야 하는 데이터 형식을 나타냅니다 (
   아래를 참조하십시오).

   Raises an auditing event "marshal.dumps" with arguments "value",
   "version".

   버전 3.13에서 변경: Added the *allow_code* parameter.

marshal.loads(bytes, /, *, allow_code=True)

   *바이트열류 객체*를 값으로 변환합니다. 유효한 값이 없으면
   "EOFError", "ValueError" 또는 "TypeError"를 발생시킵니다. 코드 객체
   는 *allow_code*가 참일 때만 지원됩니다. 입력의 여분의 바이트는 무시
   됩니다.

   Raises an auditing event "marshal.loads" with argument "bytes".

   버전 3.10에서 변경: 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.

   버전 3.13에서 변경: Added the *allow_code* parameter.

또한, 다음 상수가 정의됩니다:

marshal.version

   Indicates the format that the module uses. Version 0 is the
   historical first version; subsequent versions add new features.
   Generally, a new version becomes the default when it is introduced.

   +---------+-----------------+------------------------------------------------------+
   | Version | Available since | New features                                         |
   |=========|=================|======================================================|
   | 1       | Python 2.4      | Sharing interned strings                             |
   +---------+-----------------+------------------------------------------------------+
   | 2       | Python 2.5      | Binary representation of floats                      |
   +---------+-----------------+------------------------------------------------------+
   | 3       | Python 3.4      | Support for object instancing and recursion          |
   +---------+-----------------+------------------------------------------------------+
   | 4       | Python 3.4      | Efficient representation of short strings            |
   +---------+-----------------+------------------------------------------------------+
   | 5       | Python 3.14     | Support for "slice" objects                          |
   +---------+-----------------+------------------------------------------------------+

-[ 각주 ]-

[1] 이 모듈의 이름은 (다른 것 중에서도) Modula-3의 설계자가 사용하는
    약간의 용어에서 유래합니다. 이들은 자급적(self-contained) 형식으로
    데이터를 전달하는 데 "마샬링(marshalling)"이라는 용어를 사용합니다
    . 엄밀히 말하면, "마샬"은 내부의 어떤 데이터를 외부 형식(예를 들어
    RPC 버퍼에)으로 변환하는 것을, "역 마샬"은 그 반대 절차를 뜻합니다
    .
