[pypy-svn] r11856 - pypy/dist/pypy/lib
arigo at codespeak.net
arigo at codespeak.net
Tue May 3 15:03:25 CEST 2005
Author: arigo
Date: Tue May 3 15:03:24 2005
New Revision: 11856
Modified:
pypy/dist/pypy/lib/cPickle.py
Log:
Some temporary dark magic to produce pickled dumps that are
closer to the ones produced by cPickle in CPython.
Modified: pypy/dist/pypy/lib/cPickle.py
==============================================================================
--- pypy/dist/pypy/lib/cPickle.py (original)
+++ pypy/dist/pypy/lib/cPickle.py Tue May 3 15:03:24 2005
@@ -16,3 +16,23 @@
class BadPickleGet(UnpicklingError):
pass
+
+# ____________________________________________________________
+# XXX some temporary dark magic to produce pickled dumps that are
+# closer to the ones produced by cPickle in CPython
+
+from pickle import StringIO
+
+PythonPickler = Pickler
+class Pickler(PythonPickler):
+ def memoize(self, obj):
+ self.memo[None] = None # cPickle starts counting at one
+ return PythonPickler.memoize(self, obj)
+
+def dump(obj, file, protocol=None, bin=None):
+ Pickler(file, protocol, bin).dump(obj)
+
+def dumps(obj, protocol=None, bin=None):
+ file = StringIO()
+ Pickler(file, protocol, bin).dump(obj)
+ return file.getvalue()
More information about the Pypy-commit
mailing list