Staging
v0.5.1
https://github.com/python/cpython
Revision 70280b859eddfa178d9a5f8824112135ace87b40 authored by Guido van Rossum on 06 October 2000, 17:37:12 UTC, committed by Guido van Rossum on 06 October 2000, 17:37:12 UTC
somewhat useful to learn regular expressions, and this way it'll be
installed on Windows.

This closes bug report 115609.
1 parent 2834b97
Raw File
Tip revision: 70280b859eddfa178d9a5f8824112135ace87b40 authored by Guido van Rossum on 06 October 2000, 17:37:12 UTC
I'm moving redemo.py here from Demo/tkinter/guido, since it is
Tip revision: 70280b8
copy_reg.py
"""Helper to provide extensibility for pickle/cPickle."""

dispatch_table = {}
safe_constructors = {}

def pickle(ob_type, pickle_function, constructor_ob = None):
    dispatch_table[ob_type] = pickle_function

    if constructor_ob is not None:
        constructor(constructor_ob)

def constructor(object):
    safe_constructors[object] = 1

# Example: provide pickling support for complex numbers.

def pickle_complex(c):
    return complex, (c.real, c.imag)

pickle(type(1j), pickle_complex, complex)

back to top