[Python-checkins] CVS: python/dist/src/Lib pickle.py,1.52,1.53
Jeremy Hylton
jhylton@users.sourceforge.net
Mon, 15 Oct 2001 14:29:30 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv14137/Lib
Modified Files:
pickle.py
Log Message:
Use cStringIO when available.
Remove test code. It's available in Lib/test/picklertester.py.
Index: pickle.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** pickle.py 2001/09/21 19:21:45 1.52
--- pickle.py 2001/10/15 21:29:28 1.53
***************
*** 959,963 ****
# Shorthands
! from StringIO import StringIO
def dump(object, file, bin = 0):
--- 959,966 ----
# Shorthands
! try:
! from cStringIO import StringIO
! except ImportError:
! from StringIO import StringIO
def dump(object, file, bin = 0):
***************
*** 975,1011 ****
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()
--- 978,979 ----