Guido van Rossum | 4706562 | 1997-04-09 17:44:11 +0000 | [diff] [blame] | 1 | dispatch_table = {} |
2 | safe_constructors = {} | ||||
3 | |||||
4 | def pickle(ob_type, pickle_function, constructor_ob = None): | ||||
5 | dispatch_table[ob_type] = pickle_function | ||||
6 | |||||
7 | if (constructor_ob is not None): | ||||
8 | constructor(constructor_ob) | ||||
9 | |||||
10 | def constructor(object): | ||||
11 | safe_constructors[object] = 1 | ||||
12 | |||||
13 | def pickle_complex(c): | ||||
14 | return complex,(c.real, c.imag) | ||||
15 | |||||
16 | pickle(type(1j),pickle_complex,complex) | ||||
17 |