[Patches] [ python-Patches-424335 ] richcompare for strings

noreply@sourceforge.net noreply@sourceforge.net
Wed, 23 May 2001 21:48:50 -0700


Patches item #424335, was updated on 2001-05-15 12:54
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=424335&group_id=5470

Category: core (C code)
Group: None
Status: Open
Resolution: Accepted
Priority: 5
Submitted By: Martin v. Löwis (loewis)
>Assigned to: Martin v. Löwis (loewis)
Summary: richcompare for strings

Initial Comment:
This patch implements the tp_richcompare slot for
string objects. It shows a 8% speed-up on selected test
cases.

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2001-05-23 21:48

Message:
Logged In: YES 
user_id=31435

Oops!  Looks like I forgot to assign this back to Martin.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2001-05-22 16:04

Message:
Logged In: YES 
user_id=31435

Marked accepted.  Looks good!

Suggest

return a->ob_size == b->ob_size &&
       *a->ob_sval == *b->ob_sval &&
       memcmp(a->ob_sval, b->ob_sval, a->ob_size) == 0;

for the tail of the _PyString_Eq body as compilers should 
have an easier time of turning that into the best code for 
the platform (especially the weaker compilers do better 
optimizing expressions than across branches).  Plus it 
improves clarity, at least for me.

Unsure why the

case Py_EQ: c = c == 0; break; /* not needed here */

case is there:  if it's truly unreacable (and I agree it 
isn't), better to assert-fail if it gets there.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2001-05-22 14:31

Message:
Logged In: YES 
user_id=31435

Assigned to me.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2001-05-21 08:33

Message:
Logged In: YES 
user_id=21627

The new revision of the patch entirely removes tp_compare
for string, following discussions on python-dev. The only
direct user of string_compare has been changed to use the
new function _PyString_Eq instead.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=424335&group_id=5470