str(bigint) is slow

Bryan belred1 at yahoo.com
Fri Jul 9 07:32:26 CEST 2004


does anyone know how to make this faster?  it seems that str(x) is the slow part.


 >>> def foo():
...     t1 = time.time()
...     x = 19 ** 314159
...     t2 = time.time()
...     y = str(x)
...     t3 = time.time()
...     print y
...     t4 = time.time()
...     print t2-t1, t3-t2, t4-t3
...
 >>> foo()
<snip a print out of a billion numbers>
3.78499984741 230.490999937 0.0700001716614


thanks,

bryan



More information about the Python-list mailing list