Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 21ee37c

Browse files
author
Skip Montanaro
committed
remove spurious SET_LINENO from com_list_for and com_list_if. All they do
is slow things down unnecessarily and make tracing much more verbose. Something like def f(n): return [i for i in range(n) if i%2] should have at most two SET_LINENO instructions, not four. When tracing, the current line number should be printed once, not 2*n+1 times.
1 parent f8c8cf8 commit 21ee37c

1 file changed

Lines changed: 0 additions & 2 deletions

File tree

Python/compile.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,6 @@ com_list_for(struct compiling *c, node *n, node *e, char *t)
13761376
com_node(c, CHILD(n, 3)); /* expr */
13771377
com_addbyte(c, GET_ITER);
13781378
c->c_begin = c->c_nexti;
1379-
com_addoparg(c, SET_LINENO, n->n_lineno);
13801379
com_addfwref(c, FOR_ITER, &anchor);
13811380
com_push(c, 1);
13821381
com_assign(c, CHILD(n, 1), OP_ASSIGN, NULL);
@@ -1395,7 +1394,6 @@ com_list_if(struct compiling *c, node *n, node *e, char *t)
13951394
int anchor = 0;
13961395
int a = 0;
13971396
/* list_iter: 'if' test [list_iter] */
1398-
com_addoparg(c, SET_LINENO, n->n_lineno);
13991397
com_node(c, CHILD(n, 1));
14001398
com_addfwref(c, JUMP_IF_FALSE, &a);
14011399
com_addbyte(c, POP_TOP);

0 commit comments

Comments
 (0)