Show More
@@ -40,6 +40,36 b' else:' | |||||
40 | class_type = (type, ClassType) |
|
40 | class_type = (type, ClassType) | |
41 |
|
41 | |||
42 | #------------------------------------------------------------------------------- |
|
42 | #------------------------------------------------------------------------------- | |
|
43 | # Functions | |||
|
44 | #------------------------------------------------------------------------------- | |||
|
45 | ||||
|
46 | ||||
|
47 | def use_dill(): | |||
|
48 | """use dill to expand serialization support | |||
|
49 | ||||
|
50 | adds support for object methods and closures to serialization. | |||
|
51 | """ | |||
|
52 | # import dill causes most of the magic | |||
|
53 | import dill | |||
|
54 | ||||
|
55 | # dill doesn't work with cPickle, | |||
|
56 | # tell the two relevant modules to use plain pickle | |||
|
57 | ||||
|
58 | global pickle | |||
|
59 | import pickle | |||
|
60 | ||||
|
61 | try: | |||
|
62 | from IPython.kernel.zmq import serialize | |||
|
63 | except ImportError: | |||
|
64 | pass | |||
|
65 | else: | |||
|
66 | serialize.pickle = pickle | |||
|
67 | ||||
|
68 | # disable special function handling, let dill take care of it | |||
|
69 | can_map.pop(FunctionType, None) | |||
|
70 | ||||
|
71 | ||||
|
72 | #------------------------------------------------------------------------------- | |||
43 | # Classes |
|
73 | # Classes | |
44 | #------------------------------------------------------------------------------- |
|
74 | #------------------------------------------------------------------------------- | |
45 |
|
75 |
General Comments 0
You need to be logged in to leave comments.
Login now