Author ammar2
Recipients ammar2, docs@python, pfalcon
Date 2019-09-29.21:47:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1569793678.81.0.814413328139.issue38316@roundup.psfhosted.org>
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: <1569793678.81.0.814413328139.issue38316@roundup.psfhosted.org>
2019-09-29 21:47:58ammar2linkissue38316 messages
2019-09-29 21:47:58ammar2create