blob: 594978cdf5f5303b1f885bff5eb983e87348e376 [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{copy_reg} ---
Fred Drakeffbe6871999-04-22 21:23:22 +00002 Register \module{pickle} support functions}
Fred Drake1abf0df1998-01-21 04:58:10 +00003
Fred Drakeffbe6871999-04-22 21:23:22 +00004\declaremodule[copyreg]{standard}{copy_reg}
Fred Drakeb91e9341998-07-23 17:59:49 +00005\modulesynopsis{Register \module{pickle} support functions.}
6
7
8The \module{copy_reg} module provides support for the
Fred Drakef161c912003-12-30 22:17:16 +00009\refmodule{pickle}\refstmodindex{pickle}\ and
10\refmodule{cPickle}\refbimodindex{cPickle}\ modules. The
11\refmodule{copy}\refstmodindex{copy}\ module is likely to use this in the
Fred Drake1abf0df1998-01-21 04:58:10 +000012future as well. It provides configuration information about object
13constructors which are not classes. Such constructors may be factory
14functions or class instances.
15
Fred Drake1abf0df1998-01-21 04:58:10 +000016
17\begin{funcdesc}{constructor}{object}
Fred Drake93615652000-10-11 22:27:51 +000018 Declares \var{object} to be a valid constructor. If \var{object} is
19 not callable (and hence not valid as a constructor), raises
20 \exception{TypeError}.
Fred Drake1abf0df1998-01-21 04:58:10 +000021\end{funcdesc}
22
23\begin{funcdesc}{pickle}{type, function\optional{, constructor}}
24 Declares that \var{function} should be used as a ``reduction''
Fred Drake2f31d562002-03-19 03:33:33 +000025 function for objects of type \var{type}; \var{type} must not be a
26 ``classic'' class object. (Classic classes are handled differently;
27 see the documentation for the \refmodule{pickle} module for
28 details.) \var{function} should return either a string or a tuple
29 containing two or three elements.
Barry Warsawd44e7ad2001-11-15 23:37:26 +000030
31 The optional \var{constructor} parameter, if provided, is a
Fred Drake3ece7132000-10-10 18:36:02 +000032 callable object which can be used to reconstruct the object when
33 called with the tuple of arguments returned by \var{function} at
Fred Drake93615652000-10-11 22:27:51 +000034 pickling time. \exception{TypeError} will be raised if
35 \var{object} is a class or \var{constructor} is not callable.
Barry Warsawd44e7ad2001-11-15 23:37:26 +000036
37 See the \refmodule{pickle} module for more
38 details on the interface expected of \var{function} and
39 \var{constructor}.
Fred Drake1abf0df1998-01-21 04:58:10 +000040\end{funcdesc}