This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Micro-optimization for tuple comparison
Type: enhancement Stage: patch review
Components: Interpreter Core Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, rhettinger, serhiy.storchaka, tim.peters, vstinner
Priority: low Keywords: patch

Created on 2014-03-30 05:49 by rhettinger, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tuple_micro_optimization.diff rhettinger, 2014-03-30 05:49 review
Messages (3)
msg215166 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2014-03-30 05:49
The tuple comparison code contains an outdated comment to the effect that testing unequal lengths for an early-out may not be worth it because it is an uncommon case in real code.

While the unequal length case remains rare, the common case code (added when rich comparisons were introduced) pays a price by not being able to assume the lengths are equal.  Adding an single early length equality test saves a repeated inner loop test for "i < wlen" and a single post-loop test for "i >= wlen".
msg215179 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-03-30 11:59
This patch breaks lexicographic ordering of tuples:

(1, 2) < (1, 2, 0) < (1, 3)
msg215188 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-03-30 17:12
New changeset 16fd3f4c9128 by Raymond Hettinger in branch 'default':
Issue 21100: Amazingly, tuple lexicographic ordering was untested.
http://hg.python.org/cpython/rev/16fd3f4c9128
History
Date User Action Args
2022-04-11 14:58:00adminsetgithub: 65299
2014-03-30 17:12:16python-devsetnosy: + python-dev
messages: + msg215188
2014-03-30 17:01:54rhettingersetstatus: open -> closed
resolution: not a bug
2014-03-30 13:05:13vstinnersetnosy: + vstinner
2014-03-30 12:04:48serhiy.storchakasetmessages: + msg215179
2014-03-30 12:02:02pitrousetnosy: + tim.peters
2014-03-30 12:00:52serhiy.storchakasetmessages: - msg215179
2014-03-30 11:59:08serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg215179
2014-03-30 05:49:39rhettingercreate