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: Speeding up the interpreter with a few lines of code
Type: performance Stage: resolved
Components: Interpreter Core Versions: Python 3.3
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: pitrou Nosy List: BreamoreBoy, jneb, mark.dickinson, pitrou
Priority: normal Keywords:

Created on 2011-02-01 07:57 by jneb, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
speedpatch.c jneb, 2011-02-01 07:57 Explanation of speed patch
Messages (5)
msg127686 - (view) Author: Jurjen N.E. Bos (jneb) * Date: 2011-02-01 07:57
I found a very simple way to improve the speed of CPython a few percent on the most common platforms (i.e. x86), at the cost of only a few lines of code in ceval.c
The only problem is that I don't have any experience in patch submission.

Here are the suggested new lines (also see submitted file):

#define NEXTARG() (next_instr +=2, *(unsigned short*)&next_instr[-2])
#define PEEKARG() (*(unsigned short*)&next_instr[1])

of course this code only works on little-endian processors that allow nonaligned shorts; a change to configure might be needed (*shiver*).

Hope you like it.
msg127794 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-02-03 14:58
Ok, things are at best 3-4% faster here (often unchanged).
msg185106 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2013-03-24 01:06
3-4% faster in some cases is better than a kick in the head but is this worth pursuing?
msg185127 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2013-03-24 10:38
> ... is this worth pursuing?

Not at the expense of introducing undefined behaviour.  I suggest closing this.
msg185279 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-03-26 16:45
> Not at the expense of introducing undefined behaviour.  I suggest 
> closing this.

ok, let's do it.
History
Date User Action Args
2022-04-11 14:57:12adminsetgithub: 55296
2013-03-26 16:45:30pitrousetstatus: open -> closed
resolution: rejected
messages: + msg185279

stage: resolved
2013-03-24 10:38:49mark.dickinsonsetnosy: + mark.dickinson
messages: + msg185127
2013-03-24 01:06:00BreamoreBoysetnosy: + BreamoreBoy
messages: + msg185106
2011-02-03 14:58:33pitrousetmessages: + msg127794
versions: - Python 2.6, Python 2.5, Python 3.1, Python 2.7, Python 3.2
2011-02-02 08:12:00georg.brandlsetassignee: pitrou

nosy: + pitrou
2011-02-01 07:57:31jnebcreate