[FRPythoneers] performance of cmp()

Rahul Kumar rahulk at bhartitelesoft.com
Tue Sep 23 02:53:04 MDT 2003

I just finished writing my first python program. I have a performance
critical loop in which 2 strings are compared. My initial code looked
like this:

if a < b:
elsif a > b:

Knowing that 2 string comparisons are inefficient I found the cmp()
method and did:

i = cmp(a,b)
if i > 0:
elsif i < 0:

To my surprise the second version kept performing *slower* than the
first. Why this (unexpected) behavior?

re, rk

More information about the FRPythoneers mailing list