From ff5bc50bb0f12d5203173c7ee6840cc77a3bbe7a Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 21 Mar 2004 15:12:00 +0000 Subject: Improve byte coding for multiple assignments. Gives 30% speedup on "a,b=1,2" and 25% on "a,b,c=1,2,3". --- Python/compile.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 3 deletions(-) (limited to 'Python/compile.c') diff --git a/Python/compile.c b/Python/compile.c index f58fb83efc..328c57bb0f 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -327,6 +327,43 @@ intern_strings(PyObject *tuple) #define ABSOLUTE_JUMP(op) (op==JUMP_ABSOLUTE || op==CONTINUE_LOOP) #define GETJUMPTGT(arr, i) (GETARG(arr,i) + (ABSOLUTE_JUMP(arr[i]) ? 0 : i+3)) #define SETARG(arr, i, val) arr[i+2] = val>>8; arr[i+1] = val & 255 +#define CODESIZE(op) (HAS_ARG(op) ? 3 : 1) +#define ISBASICBLOCK(blocks, start, bytes) (blocks[start]==blocks[start+bytes-1]) + +static unsigned int * +markblocks(unsigned char *code, int len) +{ + unsigned int *blocks = PyMem_Malloc(len*sizeof(int)); + int i,j, opcode, oldblock, newblock, blockcnt = 0; + + if (blocks == NULL) + return NULL; + memset(blocks, 0, len*sizeof(int)); + for (i=0 ; i