Hello, gopy
print("Hello, gopy")
$ gopy hello.py
Hello, gopy
What just happened
-
Parse.
parser.ParseFilereadshello.py, runs the tokenizer, and runs the PEG parser. The result is an AST: a singleModulenode containing oneExprstatement that wraps aCallto aNameprintwith the string"Hello, gopy"as its argument. -
Compile.
compile.Compileruns the symbol-table builder on the AST, then the code generator, then the flow-graph optimiser, then the assembler. The output is aCodeobject. -
Run.
pythonrun.Runhands the code object to the VM. The VM creates a frame, pushes it, and enters the dispatch loop. -
Print.
LOAD_NAMEfindsprintin the builtins module.LOAD_CONSTpushes the string.CALLinvokesprint, which writes tosys.stdout.RETURN_VALUEpops the frame.
Disassembly
The compiler emits the bytecode below. The -d flag is parsed
but not yet wired in gopy; for now, the easiest way to inspect
gopy's output is to run python3 -m dis hello.py under CPython
3.14. gopy's bytecode is identical:
0 0 RESUME 0
1 2 LOAD_NAME 0 (print)
4 PUSH_NULL
6 LOAD_CONST 0 ('Hello, gopy')
8 CALL 1
16 POP_TOP
18 RETURN_CONST 1 (None)
See Debugging for the introspection surface that gopy does ship today.
Where to go from here
The Run a file page documents every shape of invocation. The CLI page documents every flag. To learn how the four stages above work, jump to the CPython internals pipeline overview and read down. The gopy pillar mirrors each page on the CPython side with the Go implementation.