cPickle alternative?

Michael Peuser mpeuser at web.de
Fri Aug 15 13:27:33 EDT 2003


o.k - I modified my testprogram - let it run at your machine.
It took 1.5 seconds - I made it 11 Million records to get  to 2 Mbyte.
Kindly
Michael
------------------
import cPickle as Pickle
from time import clock

# generate 1.000.000 records
r=[(('k', 5, 0),), (('*', 0, 0),), (('t', 1, 1),), (('o', 2, 0),), (('t', 3,
0),), (('a', 4, 0), ('o', 2, 0))]

x=[]

for i in xrange(1000000):
    x.append(r)

print len(x), "records"

t0=clock()
f=open ("test","w")
Pickle.dump(x,f,1)
f.close()
print "out=", clock()-t0

t0=clock()
f=open ("test")
x=Pickle.load(f)
f.close()
print "in=", clock()-t0
---------------------

"Drochom" <pedrosch at gazeta.pl> schrieb im Newsbeitrag
news:bhj2ah$2ke$1 at nemesis.news.tpi.pl...
> Thanks for help:)
>
> Here is simple example:
> frankly speaking it's a graph with 100000 nodes:
> STRUCTURE:
> [(('k', 5, 0),), (('*', 0, 0),), (('t', 1, 1),), (('o', 2, 0),), (('t', 3,
> 0),), (('a', 4, 0), ('o', 2, 0))]
>
> I0
> ttp5
> a((S't'
> I3
> I0
> ttp6
> a((S'a'
> I4
> I0
> t(S'o'
> I2
> I0
> ttp7
> a.
>
> Maybe now you can give me more precise advice:)
> Thanks again
>
>






More information about the Python-list mailing list