Skip to content
Advertisement

Tag: bytecode

Interpret Python bytecode in C# (with fine control)

For a project idea of mine, I have the following need, which is quite precise: I would like to be able to execute Python code (pre-compiled before hand if necessary) on a per-bytecode-instruction basis. I also need to access what’s inside the Python VM (frame stack, data stacks, etc.). Ideally, I would also like to remove a lot of Python

why if-statement not shown in opcode?

Here is a simple sample: Why does here not have bytecode about if-statement? It just directly return value. CPython3.6 Answer In Python 3, True cannot be overridden, so Python is allowed to “optimize” this and assume True will always be true. For historic reasons, Python 2 didn’t have True as a constant/keyword, so the language isn’t allowed to optimize this:

Advertisement