[issue28397] Faster index range checks

Stefan Krah report at bugs.python.org
Tue Oct 11 09:30:58 EDT 2016


Stefan Krah added the comment:

On 64-bit Linux there's no difference:

$ ./usr/bin/gcc -O3 -o issue28397-2 issue28397-2.c
$  time ./issue28397-2 0

real    0m2.486s
user    0m2.424s
sys     0m0.014s
$ time ./issue28397-2 1

real    0m2.433s
user    0m2.422s
sys     0m0.008s



Also, most of the time "index < 0 || index >= nitems" *is* inlined,
and it was at least three times faster here.


I guess the general point is that such micro-optimizations are
unpredictable on modern architectures and modern compilers.

Note that the fast inlined version used SSE instructions.

----------

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


More information about the Python-bugs-list mailing list