no sign() function ?

Istvan Albert istvan.albert at gmail.com
Mon Dec 22 15:33:12 CET 2008


> ---- conclusions -------------------------------

try testing on a large number of candidates that are all (or mostly)
positive or all (or mostly) negative and you'll see performance
numbers that are substantially different than the ones you report:

candidates = range(1000)

In general the function sign_1() is expected to be the fastest because
in most cases will detect the sign with the fewest operations, it only
visits the rest of the comparison when it hits the corner cases. Only
if you have lots of +/-0.0 cases will it be slower than the rest, due
to having to call an expensive operation.

i.



More information about the Python-list mailing list