The CPython Bytecode Compiler Is Dumb
There is a reason why basically every attempt to make this kind of language fast has to support some form of on-stack replacement.<p>For example, it&#x27;s hard to optimize even local variable dataflow in python since it&#x27;s part of the API : you can inspect the local frame of your caller, so you have a problem as soon as your function contains a single call. And no you can&#x27;t know statically what is the call target since it can be replaced dynamically.<p>So either you perform the optimization anyway and then have to try to support reconstructing values correctly to support introspection, or you just do that generically with OSR and use the simple introspection on the interpeter.<p>Either way, there are not a lot of &quot;simple optimization&quot; when the language is so dynamic.