I understand that the python compiler compiles python code into code objects, which contain the bytecode and a few other fields such as immediate values in the code block, variables, stack_sz etc. The code objects are then mapped to c functions/precompiled assemblies by the interpreter.
I am having troubles connecting this python behavior with what I learned in my compiler class. In general, compilers creates some intermediate representation of the source code and store it in a data structure such as an abstract syntax tree.
My questions is what is the relationship between python code object and AST? If you do code generation on an AST, is code object what you get? Is it possible to view the AST and manually generate code objects using python commands?
astmodule. - berealcompilefunction lets you pass source code as text (in which case it will first produce an AST) or an AST as input, and return a code object. - chepner