Add 3.12 typing features to the compiler by dchiquito · Pull Request #5302 · RustPython/RustPython
Awesome! I like the changes.
The push_symbol_table and pop_symbol_table are my attempt to simulate the behavior of the new Annotation Scopes. I'm not sure if I got this 100% right.
To be honest, I don't know well about either Annotation Scopes or our symbol table. If you are not sure about the design, leaving a comment with your concern will be fine.
@coolreader18 Do you have any advice?
At some point, CPython introduced the compiler-level concept of intrinsics. There are a handful of instructions like CALL_INTRINSIC_1 and CALL_INTRINSIC_2 that do weird fundamental python things like printing, importing, or defining types. It seems to me that this is mostly a way of organizing the code than a fundamental design requirement, so I ignored this and added the intrinsics I needed as instructions. Perhaps this is not correct?
Yes, CPython is recently very quickly changing its instruction design. Our instructions design is staying around 3.6~3.8. Your approach seems correct and fits in traditional Python instruction design well. We will be able to introduce those new concepts later. Don't worry!
I made a small change to how the bookkeeping is done for unmarshalling bytecode. Adding a new instruction caused me some very odd intermittent errors that took me a while to debug, so my hope is to prevent headaches in the future.
I am sorry to make you to be confused. How about placing a comment to the last instruction like "Please add instruction in the middle of the enum; otherwise LAST_INSTRUCTION need to be updated"