Message353511
Yeah, that parenthesized bit seems a bit weird: co_stacksize really has nothing to do with the number of variables, it's just that certain opcodes (https://docs.python.org/3/library/dis.html#python-bytecode-instructions) push and pop off the stack, co_stacksize is just the largest the stack will ever grow to from these operations.
For example:
>>> def f():
... a = 1
... b = 2
... c = 3
... g(a, b, c)
...
>>> f.__code__.co_stacksize
4
and
>>> def g():
... g(1, 2, 3)
...
>>> g.__code__.co_stacksize
4
have the exact same stack size despite differences in variables because the call to `g` has to push all 3 operands (and g itself) onto the stack. |
|
| Date |
User |
Action |
Args |
| 2019-09-29 21:47:58 | ammar2 | set | recipients:
+ ammar2, pfalcon, docs@python |
| 2019-09-29 21:47:58 | ammar2 | set | messageid: <[email protected]> |
| 2019-09-29 21:47:58 | ammar2 | link | issue38316 messages |
| 2019-09-29 21:47:58 | ammar2 | create | |
|