@@ -38,23 +38,39 @@ supports a substantially wider range of objects than marshal.
3838 maliciously constructed data. Never unmarshal data received from an
3939 untrusted or unauthenticated source.
4040
41+ There are functions that read/write files as well as functions operating on
42+ bytes-like objects.
43+
4144.. index :: object; code, code object
4245
4346Not all Python object types are supported; in general, only objects whose value
4447is independent from a particular invocation of Python can be written and read by
45- this module. The following types are supported: booleans, integers, floating-point
46- numbers, complex numbers, strings, bytes, bytearrays, tuples, lists, sets,
47- frozensets, dictionaries, and code objects (if *allow_code * is true),
48- where it should be understood that
49- tuples, lists, sets, frozensets and dictionaries are only supported as long as
50- the values contained therein are themselves supported. The
51- singletons :const: `None `, :const: `Ellipsis ` and :exc: `StopIteration ` can also be
52- marshalled and unmarshalled.
53- For format *version * lower than 3, recursive lists, sets and dictionaries cannot
54- be written (see below).
48+ this module. The following types are supported:
49+
50+ * Numeric types: :class: `int `, :class: `bool `, :class: `float `, :class: `complex `.
51+ * Strings (:class: `str `) and :class: `bytes `.
52+ :term: `Bytes-like objects <bytes-like object> ` like :class: `bytearray ` are
53+ marshalled as :class: `!bytes `.
54+ * Containers: :class: `tuple `, :class: `list `, :class: `set `, :class: `frozenset `,
55+ and (since :data: `version ` 5), :class: `slice `.
56+ It should be understood that these are supported only if the values contained
57+ therein are themselves supported.
58+ Recursive containers are supported since :data: `version ` 3.
59+ * The singletons :const: `None `, :const: `Ellipsis ` and :exc: `StopIteration `.
60+ * :class: `code ` objects, if *allow_code * is true. See note above about
61+ version dependence.
62+
63+ .. versionchanged :: 3.4
64+
65+ * Added format version 3, which supports marshalling recursive lists, sets
66+ and dictionaries.
67+ * Added format version 4, which supports efficient representations
68+ of short strings.
69+
70+ .. versionchanged :: next
71+
72+ Added format version 5, which allows marshalling slices.
5573
56- There are functions that read/write files as well as functions operating on
57- bytes-like objects.
5874
5975The module defines these functions:
6076
@@ -140,11 +156,24 @@ In addition, the following constants are defined:
140156
141157.. data :: version
142158
143- Indicates the format that the module uses. Version 0 is the historical
144- format, version 1 shares interned strings and version 2 uses a binary format
145- for floating-point numbers.
146- Version 3 adds support for object instancing and recursion.
147- The current version is 4.
159+ Indicates the format that the module uses.
160+ Version 0 is the historical first version; subsequent versions
161+ add new features.
162+ Generally, a new version becomes the default when it is introduced.
163+
164+ ======= =============== ====================================================
165+ Version Available since New features
166+ ======= =============== ====================================================
167+ 1 Python 2.4 Sharing interned strings
168+ ------- --------------- ----------------------------------------------------
169+ 2 Python 2.5 Binary representation of floats
170+ ------- --------------- ----------------------------------------------------
171+ 3 Python 3.4 Support for object instancing and recursion
172+ ------- --------------- ----------------------------------------------------
173+ 4 Python 3.4 Efficient representation of short strings
174+ ------- --------------- ----------------------------------------------------
175+ 5 Python 3.14 Support for :class: `slice ` objects
176+ ======= =============== ====================================================
148177
149178
150179.. rubric :: Footnotes
@@ -154,4 +183,3 @@ In addition, the following constants are defined:
154183 around in a self-contained form. Strictly speaking, "to marshal" means to
155184 convert some data from internal to external form (in an RPC buffer for instance)
156185 and "unmarshalling" for the reverse process.
157-
0 commit comments