How about an implementation of python that doesn't let you do fancy things like that that are not needed in production?
People have tried, pypy started with that goal before it became clear it wasn't practical.
From what I’ve seen last time I heard about graal python is that it is seldom faster than the pypy approach (AST-based vs tracing JIT), even though in case of TruffleRuby and TruffleJS it is insanely fast compared to the maturity of the projects.
Is your mentioned example of stack frame inspection make it map much worse to Java primitives (which happens behind the scenes of the truffle languages)?
How does that work and what is it used for?
https://markmail.org/message/dp56i26zhpf4fehb#query:+page:1+...
Also I think Python’s truthy/falsey semantics make it dangerously close to being weakly typed.
The single example I typically give is that in Python you can inspect stack frames after they've exited! This has concrete implications on your VM design.
Another example is that the multiple dispatch protocol for binary operations (such as addition) is sufficiently complicated that you generally cannot encode it into your compiler. We have been able to have a simplified version of that by building a tracing JIT for C, which is able to understand the dispatch protocol, but it is not always applicable.
Source: I've been working on Python optimization for several years as part of the Pyston project.