[issue30907] speed up comparisons to self for built-in containers

Serhiy Storchaka report at bugs.python.org
Fri Jul 14 01:00:57 EDT 2017


Serhiy Storchaka added the comment:

First, few comments about the code.

1) The condition "a == b" is enough. No need to test "PyDict_CheckExact(a)" and like.

2) This fast path can be used only for Py_EQ and Py_NE. For other operations it can change the behavior.

This is common approach of implementing operator== on C++. Unless comparing objects is trivial the implementation of operator== almost always starts with comparing pointers. In Python the overhead of calling methods and comparing objects is larger than in C++ and I expect that the relative overhead of one additional pointer comparison is smaller.

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30907>
_______________________________________


More information about the Python-bugs-list mailing list