Ditched '_find_SET()', since it was a no-value-added wrapper around
[python/dscho.git] / Lib / copy_reg.py
blobd0953bf08b74e35a662c33a1152c153c59903abb
1 """Helper to provide extensibility for pickle/cPickle."""
3 dispatch_table = {}
4 safe_constructors = {}
6 def pickle(ob_type, pickle_function, constructor_ob = None):
7 dispatch_table[ob_type] = pickle_function
9 if constructor_ob is not None:
10 constructor(constructor_ob)
12 def constructor(object):
13 safe_constructors[object] = 1
15 # Example: provide pickling support for complex numbers.
17 def pickle_complex(c):
18 return complex, (c.real, c.imag)
20 pickle(type(1j), pickle_complex, complex)