Basic usage
Command-line flags
Execution modes
Compile the script to bytecode and execute with the VM (default mode)This is the default execution mode when a file is provided. The bytecode VM offers better performance than the tree-walking interpreter.
Run with the tree-walking interpreter instead of the bytecode VMUseful for development and debugging. Cannot be combined with
--disassemble.Print the bytecode disassembly without executingDisplays the compiled bytecode instructions for analyzing program structure. Cannot be combined with
--interpreted.Debugging and logging
Enable debug-level loggingShows detailed internal information during execution. Sets log level to
Debug.Enable interactive debugger modeStarts the program in debugger mode with step-through execution, breakpoints, and variable inspection. See Debugging for full debugger documentation.
Enable verbose outputProvides additional information during execution.
Enable trace-level logging (most detailed)Shows extremely detailed trace information for deep debugging. Sets log level to
Trace.JIT compilation
These flags require thejit feature to be enabled during compilation.
Enable JIT compilation of hot code pathsRequires Walrus to be built with
--features jit. Hot loops are compiled to native machine code using Cranelift after 1000 iterations, providing significant performance improvements for numeric computations.Show JIT profiling statistics after executionDisplays hot-spot statistics, type profiles, and JIT compilation metrics.Example output:
Disable JIT profiling for baseline benchmarkingTurns off profiling overhead to measure baseline VM performance without hot-spot detection.
Flag combinations
Valid combinations
Invalid combinations
Some flags cannot be used together:| Flag 1 | Flag 2 | Reason |
|---|---|---|
--interpreted | --disassemble | Interpreter doesn’t use bytecode |
File argument
The script file to execute (optional)If no file is provided, Walrus starts in REPL mode. The file should contain valid Walrus source code with a
.walrus extension.Exit codes
The Walrus CLI uses standard exit codes:| Code | Meaning |
|---|---|
0 | Successful execution |
1 | Runtime error or exception |
| Custom | Program-specific (via sys.exit(code)) |