summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-10-15 21:29:28 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-10-15 21:29:28 (GMT)
commitabe2c62bdb26742379a7082f31821bacfc22106f (patch)
tree879687845c013b87e114e9d21b2fca4899bbf6d9 /Lib/pickle.py
parent2ef1b8fd972c9d9169654dcf887e75f87bb3ef6f (diff)
downloadcpython-abe2c62bdb26742379a7082f31821bacfc22106f.zip
cpython-abe2c62bdb26742379a7082f31821bacfc22106f.tar.gz
cpython-abe2c62bdb26742379a7082f31821bacfc22106f.tar.bz2
Use cStringIO when available.
Remove test code. It's available in Lib/test/picklertester.py.
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r--Lib/pickle.py40
1 files changed, 4 insertions, 36 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 9b59de8..d77e33e 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -958,7 +958,10 @@ class _EmptyClass:
# Shorthands
-from StringIO import StringIO
+try:
+ from cStringIO import StringIO
+except ImportError:
+ from StringIO import StringIO
def dump(object, file, bin = 0):
Pickler(file, bin).dump(object)
@@ -974,38 +977,3 @@ def load(file):
def loads(str):
file = StringIO(str)
return Unpickler(file).load()
-
-
-# The rest is used for testing only
-
-class C:
- def __cmp__(self, other):
- return cmp(self.__dict__, other.__dict__)
-
-def test():
- fn = 'out'
- c = C()
- c.foo = 1
- c.bar = 2
- x = [0, 1, 2, 3]
- y = ('abc', 'abc', c, c)
- x.append(y)
- x.append(y)
- x.append(5)
- f = open(fn, 'w')
- F = Pickler(f)
- F.dump(x)
- f.close()
- f = open(fn, 'r')
- U = Unpickler(f)
- x2 = U.load()
- print x
- print x2
- print x == x2
- print map(id, x)
- print map(id, x2)
- print F.memo
- print U.memo
-
-if __name__ == '__main__':
- test()