Issue 1492860: Integer bit operations performance improvement. (original) (raw)

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:17 admin set github: 43395
2009-04-29 09🔞16 mark.dickinson set status: open -> closedresolution: rejectedmessages: +
2009-04-28 21:52:52 pitrou set nosy: + pitroumessages: +
2009-04-28 17:26:18 ajaksu2 set dependencies: - long int bitwise ops speedup (patch included)messages: +
2009-04-27 16:42:47 mark.dickinson set messages: +
2009-04-26 01:08:53 ajaksu2 set nosy: + ajaksu2dependencies: + long int bitwise ops speedup (patch included)messages: +
2009-03-21 15:51:59 mark.dickinson set keywords: + easystage: test needed -> needs patchmessages: + versions: - Python 3.1
2009-03-21 15:05:22 mark.dickinson set nosy: + mark.dickinson
2009-03-21 02:47:09 ajaksu2 set stage: test neededversions: + Python 3.1, Python 2.7
2008-03-16 21:07:08 georg.brandl set type: enhancement -> performance
2006-05-22 11:43:04 jafo create