Warnings killing my performance
Skip Montanaro
skip at pobox.com
Fri Feb 6 15:04:08 EST 2004
Ben> So I have these problems: warnings are slow (even when disabled),
Ben> sometimes warnings are being issued and I never see them, and given
Ben> that I never see the warnings I don't know how to get around them.
Ben> So, my first question is to ask if there is a more efficient way of
Ben> disabling warnings?
This may seem silly, but switching to the CVS version of Python (aka 2.4a0)
should help immensely, simply because that is gone:
% python2.3 ~/local/bin/timeit.py -s 'import sys ; sys.path.append("/Users/skip/tmp"); from warn import IntToRandFloat' 'IntToRandFloat(789221)'
/Users/skip/tmp/warn.py:4: FutureWarning: x<<y losing bits or changing sign will return a long in Python 2.4 and up
x = int(x << 13) ^ x
10000 loops, best of 3: 114 usec per loop
% python2.4 ~/local/bin/timeit.py -s 'import sys ; sys.path.append("/Users/skip/tmp"); from warn import IntToRandFloat' 'IntToRandFloat(789221)'
100000 loops, best of 3: 16.7 usec per loop
Ben> Lastly, a suggestion; if 2.4 will introduce an automatic promotion
Ben> to a long as a result of this shift operation, will the standard
Ben> library provide a C implementation of the lossy shift operator for
Ben> those of us that would benefit from a quick version? I'm guessing
Ben> that promoting it to a long and then getting it back to a normal
Ben> int is not exactly the speediest operation.
Apparently it's quite a bit faster than navigating all the warning
machinery. ;-)
Skip
More information about the Python-list
mailing list