Why not do this at a higher level on the python source itself?<p>I ask because z3 has been used for type inference (Typpete) and for solving equations written in Python.
Compile enough traces with the accompanying optimizations and you have solid training data for an LLM that can suggest optimizations based on JIT traces.