[ create a new paste ] login | about

Link: http://codepad.org/YkV7YFdq    [ raw code | output | fork ]

Python, pasted on Nov 30:
n = 13**666

def tostr(l):
    return str(l)

def tolong(s):
    return long(s)

import marshal
import cPickle
import time
print "Marshal:"
s = time.time()
for i in xrange(1000):
    marshal.loads(marshal.dumps(n))
print "Took %f seconds" % (time.time() - s)

print "cPickle:"
s = time.time()
for i in xrange(1000):
    cPickle.loads(cPickle.dumps(n))
print "Took %f seconds" % (time.time() - s)

print "Natives:"
s = time.time()
for i in xrange(1000):
    tolong(tostr(n))
print "Took %f seconds" % (time.time() - s)


Output:
1
2
3
4
5
6
Marshal:
Took 0.035474 seconds
cPickle:
Took 0.769858 seconds
Natives:
Took 0.783205 seconds


Create a new paste based on this one


Comments: