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: Integer bit operations performance improvement.
Type: performance Stage: needs patch
Components: Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, jafo, mark.dickinson, pitrou, tim.peters
Priority: low Keywords: easy

Created on 2006-05-22 11:43 by jafo, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (8)
msg54813 - (view) Author: Sean Reifschneider (jafo) * (Python committer) Date: 2006-05-22 11:43
At the Need for Speed sprint, Tim Peters asked if
anyone had any need for integer bit operation
performance improvement.  Apparently, it's easy to
improve, but nobody has said they need this.  Please
reply to this task if you have an application which
needs this.
msg54814 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2006-05-22 12:29
Logged In: YES 
user_id=31435

Changed Category to Performance.  The idea with this one is
that the eval loop could easily inline "int & int", "int |
int", "int ^ int", much as it inlines "int + int" today.
msg83937 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-03-21 15:51
To see what Tim's talking about here, see the 'big switch' ("switch 
opcode") in function PyEval_EvalFrameEx in Python/ceval.c, and look at the 
"case BINARY_ADD" bit.  Inlining the bitwise operators should be even 
easier, since there are no overflow worries.  (We do have to assume that C 
longs are two's-complement with no trap representation, but 
Objects/intobject.c does that already, so it's probably okay.)

This only applies to 'short' integers, so I don't think it's relevant for 
Python 3.x.
msg86584 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-04-26 01:08
There's a related patch in issue 1087418.
msg86678 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-04-27 16:42
I agree issue 1087418 is related, but why is it marked as a dependency for 
this issue?  It seems to me that either of these feature requests could be 
implemented independently of the other:  this one applies only to 2.x 
ints, while issue 1087418 applies only to 2.x longs and 3.x ints.
msg86754 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-04-28 17:26
Mark: it was just my cluelessness showing :)
msg86768 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-04-28 21:52
I don't think it's a good thing to special-case bitwise operations in
the ceval loop. It will make the whole thing less instruction
cache-friendly, just for the purpose of speeding up some very uncommon
operations.
msg86787 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-04-29 09:18
It looks like no-one sees this as a useful optimization;  it seems even
less useful now given that it's not applicable to Python 3.x.

Closing.
History
Date User Action Args
2022-04-11 14:56:17adminsetgithub: 43395
2009-04-29 09:18:16mark.dickinsonsetstatus: open -> closed
resolution: rejected
messages: + msg86787
2009-04-28 21:52:52pitrousetnosy: + pitrou
messages: + msg86768
2009-04-28 17:26:18ajaksu2setdependencies: - long int bitwise ops speedup (patch included)
messages: + msg86754
2009-04-27 16:42:47mark.dickinsonsetmessages: + msg86678
2009-04-26 01:08:53ajaksu2setnosy: + ajaksu2
dependencies: + long int bitwise ops speedup (patch included)
messages: + msg86584
2009-03-21 15:51:59mark.dickinsonsetkeywords: + easy

stage: test needed -> needs patch
messages: + msg83937
versions: - Python 3.1
2009-03-21 15:05:22mark.dickinsonsetnosy: + mark.dickinson
2009-03-21 02:47:09ajaksu2setstage: test needed
versions: + Python 3.1, Python 2.7
2008-03-16 21:07:08georg.brandlsettype: enhancement -> performance
2006-05-22 11:43:04jafocreate