[Python-Dev] Comparison speed

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Wed, 16 May 2001 10:02:01 +0200


> Since that's the exact opposite of what I want to do, it's at least
> interesting <wink>.

I'll put a patch on SF soon which does what you want to do, i.e. tries
tp_compare as the first thing if tp_richcompare is not there. Even
with this patch, your code is faster if strings have a
richcompare. Without richcompare, I get

0.720
0.720
0.720
0.730
0.720
0.720
0.730
0.720
0.720
0.730

With it, I get

0.710
0.720
0.720
0.710
0.710
0.720
0.710
0.710
0.710
0.720

Given that stock CVS python is in the 0.78 range, the different is
neglectable, though.

Regards,
Martin