classification
Title: Speeding up the interpreter with a few lines of code
Type: performance Stage:
Components: Interpreter Core Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: pitrou Nosy List: jneb, pitrou
Priority: normal Keywords:

Created on 2011-02-01 07:57 by jneb, last changed 2011-02-03 14:58 by pitrou.

Files
File name Uploaded Description Edit
speedpatch.c jneb, 2011-02-01 07:57 Explanation of speed patch
Messages (2)
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).
History
Date User Action Args
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