monkey_patched_pickle

This commit is contained in:
mdipierro
2013-08-27 15:55:01 -05:00
parent 371a4780e8
commit a08cd3e8ff
3 changed files with 13 additions and 2 deletions
+9
View File
@@ -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