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
gopy -d hello.py prints the bytecode the compiler produced.
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)
This is byte-for-byte identical to what CPython 3.14 produces.
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.