[issue3106] speedup some comparisons
Raymond Hettinger
report at bugs.python.org
Sun Nov 16 16:13:32 CET 2008
Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:
You may get better timings if you more the types-are-equal test inside
the types-i-know test. Instead of:
+ if (Py_TYPE(v) == Py_TYPE(w)) {
+ if (PyLong_CheckExact(v)) {
+ if (v == w)
+ break;
+ return PyLong_RichCompare(v, w, op);
+ }
+ if (PyUnicode_CheckExact(v)) {
Do something like:
+ if (PyLong_CheckExact(v)) {
+ if (Py_TYPE(v) == Py_TYPE(w)) {
+ if (v == w)
+ break;
+ return PyLong_RichCompare(v, w, op);
+ }
+ if (PyUnicode_CheckExact(v)) {
+ if (Py_TYPE(v) == Py_TYPE(w)) {
In general, I'm not too keen on adding this kind of dispatch code to
ceval.c. It saves the time spent in PyObject_RichCompare() trying to
figure out where to delegate the work. But it comes at the expense of
weighing down ALL of the other comparisons which haven't gotten a
short-cut specialization.
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3106>
_______________________________________
More information about the Python-bugs-list
mailing list