Skip to main content

Command line interface

gopy [options] [-c cmd | -m mod | file | -] [arg ...]

Every option below matches the CPython option of the same name. The argument parser lives in getopt/ and mirrors Modules/getpath.c and Modules/main.c.

Quick reference

OptionMeaning
-c cmdRun cmd as a single statement. Following arguments go to sys.argv.
-m modImport mod and run it as __main__.
-Read the program from stdin.
-iDrop into the REPL after the script runs.
-qSuppress the startup banner in the REPL.
-uForce unbuffered binary stdout / stderr.
-vVerbose import tracing. Repeat for more detail.
-OStrip assertions. __debug__ becomes false.
-OOLike -O but also strip docstrings.
-SSkip implicit import site on startup.
-EIgnore PYTHON* environment variables.
-IIsolated mode: -E -s -P and friends combined.
-sDon't add the user site directory to sys.path.
-dPrint the disassembly of the program and exit.
-X optSet an implementation option; see the table below.
--versionPrint version and exit.
--helpPrint this list and exit.

-X options

Forwarded to sys._xoptions. The names below have observable behaviour in gopy today.

NameEffect
devEnable runtime checks (PEP 690 dev mode).
tracemalloc=NAllocate N frames of malloc traceback per object.
pycache_prefix=PWrite __pycache__ under prefix P.
int_max_str_digits=NCap the digit count for int-to-str conversions.
gil=1Use the global-interpreter-lock build (default).

Environment variables

VariableEffect
PYTHONPATHPrepended to sys.path.
PYTHONHOMEOverride the default install root.
PYTHONSTARTUPFile evaluated before the REPL.
PYTHONDONTWRITEBYTECODEDisable .pyc writing.
PYTHONUNBUFFEREDEquivalent to -u.
PYTHONVERBOSEEquivalent to -v.
PYTHONOPTIMIZESet the same level -O would.
PYTHONHASHSEEDSeed str / bytes hashing.
PYTHONIOENCODINGForce encoding of standard streams.
PYTHONUTF8Force UTF-8 mode for filesystem and standard streams.

gopy-only switches

These flags do not exist in CPython. Each is a runtime knob for the gopy implementation itself, not a language extension.

FlagEffect
GOPY_TRACE_SPECIALIZER=1Log every specializer hit / miss / deopt.
GOPY_TRACE_TIER2=1Log Tier-2 trace projection and execution.
GOPY_TRACE_MONITOR=1Log every sys.monitoring fire.
GOPY_DUMP_CODE=1Dump every compiled Code object.