[Python-ideas] More compact bytecode

Antoine Pitrou solipsis at pitrou.net
Sun Feb 7 07:54:29 EST 2016


On Sun, 7 Feb 2016 09:18:18 +0200
Serhiy Storchaka <storchaka at gmail.com>
wrote:
> On 06.02.16 21:18, Antoine Pitrou wrote:
> > It sounds like, by 16-bit opcodes, you mean combine the opcode and the
> > argument in
> > a single 16-bit word.  But that doesn't solve the issue you want to solve: you
> > still have to decode the argument encoded in the 16-bit word.  I don't see
> > where the benefit is.
> 
> Current code uses 3 read operations:
> 
>      opcode = *next_instr++;
>      next_instr += 2;
>      oparg = (next_instr[-1]<<8) + next_instr[-2];
> 
> Even combining the latter two operations in one read operation give as 
> 10% gain in the microbenchmark (see http://bugs.python.org/issue25823):
> 
>      opcode = *next_instr++;
>      oparg = *(unsigned short *)next_instr;
>      next_instr += 2;

So it remains to be seen how much performance is won on actual
non-silly benchmarks ;-)

Regards

Antoine.




More information about the Python-ideas mailing list