Closed
Description
Now:
Python 3.11.0a7+ (main, Apr 11 2022, 20:06:08) [MSC v.1931 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> def f(): ... for i in range(2): ... print(i) ... >>> __ltrace__ = 1 >>> f() -1: 151, 0 0: 2 1: 101, 0 push <function f at 0x00000256998C2360> 2: 166, 0 3: 171, 0 stackadj <function f at 0x00000256998C2360> stackadj <function f at 0x00000256998C2360> -1: 151, 0 0: 116, 1 stackadj <nil> push <class 'range'> 1: 100, 1 push 2 7: 166, 1 8: 171, 1 stackadj 2 stackadj <class 'range'> push range(0, 2) 10: 68 push 0 pop 0 17: 116, 3 stackadj <nil> push <built-in function print> 18: 124, 0 push 0 24: 166, 1 25: 171, 1 0 stackadj 0 stackadj <built-in function print> push None 27: 1 pop None 32: 140, 18 33: 93, 17 push 1 pop 1 17: 116, 3 stackadj <nil> push <built-in function print> 18: 124, 0 push 1 24: 166, 1 25: 171, 1 1 stackadj 1 stackadj <built-in function print> push None 27: 1 pop None 32: 140, 18 33: 93, 17 stackadj <range_iterator object at 0x000002569973F240> 16: 100, 0 push None 34: 83 pop None 9: 70 pop None 10: 100, 0 push None 11: 83 pop None
What's possible:
Python 3.11.0a7+ (main, Apr 11 2022, 20:06:08) [MSC v.1931 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> def f(): ... for i in range(2): ... print(i) ... >>> __ltrace__ = 1 >>> f() Resuming frame for '<module>' [] -1: RESUME 0 [] 0: PUSH_NULL [<nil>, ] 1: LOAD_NAME 0 [<nil>, <function f at 0x0000016650F52360>, ] 2: PRECALL 0 [<nil>, <function f at 0x0000016650F52360>, ] 3: CALL 0 Resuming frame for 'f' in module '__main__' [] -1: RESUME 0 [] 0: LOAD_GLOBAL 1 [<nil>, <class 'range'>, ] 1: LOAD_CONST 1 [<nil>, <class 'range'>, 2, ] 7: PRECALL 1 [<nil>, <class 'range'>, 2, ] 8: CALL 1 [range(0, 2), ] 10: GET_ITER [<range_iterator object at 0x0000016650D3F240>, ] 17: LOAD_GLOBAL 3 [<range_iterator object at 0x0000016650D3F240>, <nil>, <built-in function print>, ] 18: LOAD_FAST 0 [<range_iterator object at 0x0000016650D3F240>, <nil>, <built-in function print>, 0, ] 24: PRECALL 1 [<range_iterator object at 0x0000016650D3F240>, <nil>, <built-in function print>, 0, ] 25: CALL 1 0 [<range_iterator object at 0x0000016650D3F240>, None, ] 27: POP_TOP [<range_iterator object at 0x0000016650D3F240>, ] 32: JUMP_BACKWARD 18 [<range_iterator object at 0x0000016650D3F240>, ] 33: FOR_ITER 17 [<range_iterator object at 0x0000016650D3F240>, ] 17: LOAD_GLOBAL 3 [<range_iterator object at 0x0000016650D3F240>, <nil>, <built-in function print>, ] 18: LOAD_FAST 0 [<range_iterator object at 0x0000016650D3F240>, <nil>, <built-in function print>, 1, ] 24: PRECALL 1 [<range_iterator object at 0x0000016650D3F240>, <nil>, <built-in function print>, 1, ] 25: CALL 1 1 [<range_iterator object at 0x0000016650D3F240>, None, ] 27: POP_TOP [<range_iterator object at 0x0000016650D3F240>, ] 32: JUMP_BACKWARD 18 [<range_iterator object at 0x0000016650D3F240>, ] 33: FOR_ITER 17 [] 16: LOAD_CONST 0 [None, ] 34: RETURN_VALUE Resuming frame for '<module>' [None, ] 9: PRINT_EXPR [] 10: LOAD_CONST 0 [None, ] 11: RETURN_VALUE
This can make use of the new _PyOpcode_OpName[256]
from #91428.