mirror of
https://github.com/python/cpython.git
synced 2025-11-13 15:40:05 +00:00
parent
cd8474e6a2
commit
2744f43f71
1 changed files with 6 additions and 6 deletions
|
|
@ -18,13 +18,13 @@ structure. ``Pickling'' is the process whereby a Python object
|
||||||
hierarchy is converted into a byte stream, and ``unpickling'' is the
|
hierarchy is converted into a byte stream, and ``unpickling'' is the
|
||||||
inverse operation, whereby a byte stream is converted back into an
|
inverse operation, whereby a byte stream is converted back into an
|
||||||
object hierarchy. Pickling (and unpickling) is alternatively known as
|
object hierarchy. Pickling (and unpickling) is alternatively known as
|
||||||
``serialization'', ``marshaling\footnote{Don't confuse this with the
|
``serialization'', ``marshalling,''\footnote{Don't confuse this with
|
||||||
\module{marshal}\refmodule{marshal} module}'', or ``flattening'',
|
the \refmodule{marshal} module} or ``flattening'',
|
||||||
however the preferred term used here is ``pickling'' and
|
however the preferred term used here is ``pickling'' and
|
||||||
``unpickling'' to avoid confusing.
|
``unpickling'' to avoid confusing.
|
||||||
|
|
||||||
This documentation describes both the \module{pickle} module and the
|
This documentation describes both the \module{pickle} module and the
|
||||||
\module{cPickle}\refmodule{cPickle} module.
|
\refmodule{cPickle} module.
|
||||||
|
|
||||||
\subsection{Relationship to other Python modules}
|
\subsection{Relationship to other Python modules}
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ The data streams the two modules produce are guaranteed to be
|
||||||
interchangeable.
|
interchangeable.
|
||||||
|
|
||||||
Python has a more primitive serialization module called
|
Python has a more primitive serialization module called
|
||||||
\module{marshal}\refmodule{marshal}, but in general
|
\refmodule{marshal}, but in general
|
||||||
\module{pickle} should always be the preferred way to serialize Python
|
\module{pickle} should always be the preferred way to serialize Python
|
||||||
objects. \module{marshal} exists primarily to support Python's
|
objects. \module{marshal} exists primarily to support Python's
|
||||||
\file{.pyc} files.
|
\file{.pyc} files.
|
||||||
|
|
@ -457,7 +457,7 @@ unpickled object.
|
||||||
|
|
||||||
An alternative to implementing a \method{__reduce__()} method on the
|
An alternative to implementing a \method{__reduce__()} method on the
|
||||||
object to be pickled, is to register the callable with the
|
object to be pickled, is to register the callable with the
|
||||||
\refmodule{copy_reg} module. This module provides a way
|
\refmodule[copyreg]{copy_reg} module. This module provides a way
|
||||||
for programs to register ``reduction functions'' and constructors for
|
for programs to register ``reduction functions'' and constructors for
|
||||||
user-defined types. Reduction functions have the same semantics and
|
user-defined types. Reduction functions have the same semantics and
|
||||||
interface as the \method{__reduce__()} method described above, except
|
interface as the \method{__reduce__()} method described above, except
|
||||||
|
|
@ -597,7 +597,7 @@ One common feature that both modules implement is the
|
||||||
\member{__safe_for_unpickling__} attribute. Before calling a callable
|
\member{__safe_for_unpickling__} attribute. Before calling a callable
|
||||||
which is not a class, the unpickler will check to make sure that the
|
which is not a class, the unpickler will check to make sure that the
|
||||||
callable has either been registered as a safe callable via the
|
callable has either been registered as a safe callable via the
|
||||||
\refmodule{copy_reg} module, or that it has an
|
\refmodule[copyreg]{copy_reg} module, or that it has an
|
||||||
attribute \member{__safe_for_unpickling__} with a true value. This
|
attribute \member{__safe_for_unpickling__} with a true value. This
|
||||||
prevents the unpickling environment from being tricked into doing
|
prevents the unpickling environment from being tricked into doing
|
||||||
evil things like call \code{os.unlink()} with an arbitrary file name.
|
evil things like call \code{os.unlink()} with an arbitrary file name.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue