[New-bugs-announce] [issue41902] Micro optimization for range.index if step is 1

Dong-hee Na report at bugs.python.org
Thu Oct 1 09:42:45 EDT 2020


New submission from Dong-hee Na <donghee.na92 at gmail.com>:

if we declare range without setting step, we don't have to process divide operation.

here is the benchmark result both setting step and without step,

With my patch, there is no performance degrade with range.index when the step is not one and showing 19% enhancement when the step is the default value (1) .

Mean +- std dev: [range_master] 1.11 us +- 0.01 us -> [range_opt] 896 ns +- 23 ns: 1.24x faster (-19%)

Mean +- std dev: [range_step_master] 1.12 us +- 0.02 us -> [range_step_opt] 1.11 us +- 0.01 us: 1.01x faster (-1%)

----------
assignee: corona10
components: Interpreter Core
files: bench_range_index.py
messages: 377752
nosy: corona10, pablogsal, serhiy.storchaka, vstinner
priority: normal
severity: normal
status: open
title: Micro optimization for range.index if step is 1
type: performance
versions: Python 3.10
Added file: https://bugs.python.org/file49482/bench_range_index.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41902>
_______________________________________


More information about the New-bugs-announce mailing list