Gzip problems

Chris AtLee catlee at canada.com
Sun Jul 8 02:19:05 CEST 2001


Hi there,

In python 2.0, the following two code segments have problems:
------
import gzip, cPickle
a = "Hello World"
cPickle.dump(a, gzip.open("hello","w"))
del a
a = cPickle.load(gzip.open("hello")) # decompression problems
print a
------
import gzip, cPickle
a = [0,] * 1024 * 1024
f = gzip.open("array","w")
print "Saving"
cPickle.dump(a, f)
f.close()
del a
print "Loading"
a = cPickle.load(gzip.open("array")) # gets stuck here
print len(a)

------
I believe the first problem is a result of the gzip file not being flushed
when the object is deleted.  The second problem I have no idea about...It
works when the object being dumped is fairly small, but for large objects it
doesn't work.  There are workarounds for both, but I'd rather fix these and
be able to do the intuitive thing :)

Cheers,
Chris







More information about the Python-list mailing list