W
Willem
When I run the follwing code using Python 2.3:
from time import clock
t1 = clock ()
for i in range (10000): a = int ('bbbbaaaa', 16)
t2 = clock ()
for i in range (10000): a = long ('bbbbaaaa', 16)
t3 = clock ()
print (t2-t1) / (t3-t2)
it prints out: 23.9673206147
That seems to mean that the int-conversion is 24 times slower than the
long conversion.
The reason is that in Python 2.3 the int-conversion generates
warning messages that you *never* see but that consume a *lot* of CPU.
So it may happen that old code performing well under Python 2.2 suddenly
slows down a considerable amount under Python 2.3 without any percievable
change in the output ...
Willem Vree
BTW.
The message that you don't see is: OverflowWarning: string/unicode conversion
and you can make it appear by starting the progam with
import warnings
warnings.resetwarnings()
I suppose that Python is getting over-engineered by too professional
programmers. The first signs of decay?
from time import clock
t1 = clock ()
for i in range (10000): a = int ('bbbbaaaa', 16)
t2 = clock ()
for i in range (10000): a = long ('bbbbaaaa', 16)
t3 = clock ()
print (t2-t1) / (t3-t2)
it prints out: 23.9673206147
That seems to mean that the int-conversion is 24 times slower than the
long conversion.
The reason is that in Python 2.3 the int-conversion generates
warning messages that you *never* see but that consume a *lot* of CPU.
So it may happen that old code performing well under Python 2.2 suddenly
slows down a considerable amount under Python 2.3 without any percievable
change in the output ...
Willem Vree
BTW.
The message that you don't see is: OverflowWarning: string/unicode conversion
and you can make it appear by starting the progam with
or including the following lines in the source text:Python -Wall script.py
import warnings
warnings.resetwarnings()
I suppose that Python is getting over-engineered by too professional
programmers. The first signs of decay?