Feature or enhancement
list.__contains__(), index(), count(), remove(), and element comparisons in list.__eq__() use PyObject_RichCompareBool() for each element.
During a scan, the search value is fixed. Since we already know its type and its value, when an element has the same exact built-in type (int, float, or str), its comparison implementation is already known. Going through generic rich-comparison dispatch adds unnecessary type-dispatch and slot-handling overhead.
Add a fast path for these exact-type pairs, fall back to PyObject_RichCompareBool() for other cases.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
Feature or enhancement
list.__contains__(),index(),count(),remove(), and element comparisons inlist.__eq__()usePyObject_RichCompareBool()for each element.During a scan, the search value is fixed. Since we already know its type and its value, when an element has the same exact built-in type (int, float, or str), its comparison implementation is already known. Going through generic rich-comparison dispatch adds unnecessary type-dispatch and slot-handling overhead.
Add a fast path for these exact-type pairs, fall back to
PyObject_RichCompareBool()for other cases.Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs