[New-bugs-announce] [issue28397] Faster index range checks
Serhiy Storchaka
report at bugs.python.org
Sun Oct 9 08:32:05 EDT 2016
New submission from Serhiy Storchaka:
The expression for testing that some index is in half-open range from 0 to limit can be written as
index >= 0 && index < limit
or as
(size_t)index < (size_t)limit
The latter form generates simpler machine code. This is idiomatic code, it is used in many C and C++ libraries (including C++ stdlib implementations). It already is used in CPython (in deque implementation).
Proposed patch rewrites index range checks in more efficient way. The patch was generated automatically by coccinelle script, and then manually cleaned up.
----------
components: Extension Modules, Interpreter Core
files: check_index.patch
keywords: patch
messages: 278355
nosy: serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Faster index range checks
type: performance
versions: Python 3.7
Added file: http://bugs.python.org/file45034/check_index.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28397>
_______________________________________
More information about the New-bugs-announce
mailing list