This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: richcompare for strings
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: loewis Nosy List: loewis, tim.peters
Priority: normal Keywords: patch

Created on 2001-05-15 19:54 by loewis, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
string.patch loewis, 2001-05-21 15:33
Messages (6)
msg36585 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2001-05-15 19:54
This patch implements the tp_richcompare slot for
string objects. It shows a 8% speed-up on selected test
cases.
msg36586 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2001-05-21 15:33
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.
msg36587 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-05-22 21:31
Logged In: YES 
user_id=31435

Assigned to me.
msg36588 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-05-22 23:04
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.
msg36589 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-05-24 04:48
Logged In: YES 
user_id=31435

Oops!  Looks like I forgot to assign this back to Martin.
msg36590 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2001-06-02 10:15
Logged In: YES 
user_id=21627

Committed as  2.117 of stringobject.c, 2.95 of 
dictobject.c, and 2.27 of stringobject.h.
History
Date User Action Args
2022-04-10 16:04:03adminsetgithub: 34507
2001-05-15 19:54:03loewiscreate