➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ammar2
Recipients ammar2, docs@python, pfalcon
Date 2019-09-29.21:47:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <[email protected]>
In-reply-to
Content
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.
History
Date User Action Args
2019-09-29 21:47:58ammar2setrecipients: + ammar2, pfalcon, docs@python
2019-09-29 21:47:58ammar2setmessageid: <[email protected]>
2019-09-29 21:47:58ammar2linkissue38316 messages
2019-09-29 21:47:58ammar2create