Irit Katriel added the comment:
stack_effect is implemented in compile.c because it is used there.
If you need something for an application like bytecode, it doesn't need to be
in the cpython c code. It can be in the standard library in opcode.py, or even
in bytecode library itself. The ques
New submission from Matthieu Dartiailh :
When constructing bytecode object manually as can be done using the bytecode
library (https://github.com/MatthieuDartiailh/bytecode which was first
developed by V Stinner), one can use dis.stack_effect to compute the required
stack size, thus avoiding