[issue41902] Micro optimization for range.index if step is 1
Dong-hee Na
report at bugs.python.org
Fri Oct 2 02:55:18 EDT 2020
Dong-hee Na <donghee.na92 at gmail.com> added the comment:
@vstinner @pablo @mark
On my local machine (without cpu isolation),
PR 22480 does not affect performance issues.
import pyperf
runner = pyperf.Runner()
runner.timeit(name="bench long divide",
stmt="""
for i in range(1, 256):
a = 10000 // i
""")
but I think that my benchmark does not cover the worst case.
I need to set up the CPU isolation environment but my resource is limited.
(I need a Linux machine with sufficient permission but not)
PR 22479 and PR 22480 has two sides of assumption.
PR 22479: PyNumber_FloorDivide is a heavy operation if the user thinks that this is an unnecessary operation it should be avoided.
(In this case divide by one)
PR 22480: PyNumber_FloorDivide should process handle unnecessary operations smartly.
In conclusion, I'd like to +1 on mark's decision.
- PR 22480: even though the divisor value is one, if the dividend is not qualified from PyLong_CheckExact it will not get an optimization path.
So it will not cover all the 'divide by one' case and it can cause performance issues.
- PR 22480: Always optimized if the user does not set a specific step value and this will be same effect on PR 22492.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41902>
_______________________________________
More information about the Python-bugs-list
mailing list