monkey_patched_pickle
This commit is contained in:
committed by
Michele Comitini
parent
dafbc17826
commit
aebb331fe7
@@ -0,0 +1,9 @@
|
||||
from pickle import Pickler, MARK, DICT, EMPTY_DICT
|
||||
from types import DictionaryType
|
||||
|
||||
def save_dict(self, obj):
|
||||
self.write(EMPTY_DICT if self.bin else MARK+DICT)
|
||||
self.memoize(obj)
|
||||
self._batch_setitems([(key,obj[key]) for key in sorted(obj)])
|
||||
|
||||
Pickler.dispatch[DictionaryType] = save_dict
|
||||
Reference in New Issue
Block a user