[Python-Dev] short fetch for NEXTARG macro (was: one byte byte code arguments)

Antoine Pitrou solipsis at pitrou.net
Mon Jan 31 13:45:26 CET 2011


On Mon, 31 Jan 2011 13:28:39 +0100
"Jurjen N.E. Bos" <Jurjen.Bos at hetnet.nl> wrote:
> I just did it: my first python source code hack.
> I replaced the NEXTARG and PEEKARG macros in ceval.c using a cast to  
> short pointer, and lo and behold, a crude measurement indicates one  
> to two percent speed increase.
> That isn't much, but it is virtually for free!
> 
> Here are the macro's I used:
> #define NEXTARG() (next_instr +=2, *(short*)&next_instr[-2])
> #define PEEKARG() (*(short*)&next_instr[1])

Some architectures forbid unaligned access, so this can't be used as-is.

Regards

Antoine.




More information about the Python-Dev mailing list