Skip to content

Commit e55beb8

Browse files
committed
bpo-39427: Document -X opt options in the CLI --help
1 parent 1f0f102 commit e55beb8

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Document all possibilities for the ``-X`` options in the command line help
2+
section. Patch by Pablo Galindo.

Python/initconfig.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,37 @@ static const char usage_3[] = "\
6363
-W arg : warning control; arg is action:message:category:module:lineno\n\
6464
also PYTHONWARNINGS=arg\n\
6565
-x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\
66-
-X opt : set implementation-specific option\n\
66+
-X opt : set implementation-specific option. The following options are available:\n\
67+
-X faulthandler: enable faulthandler\n\
68+
-X showrefcount: output the total reference count and number of used\n\
69+
memory blocks when the program finishes or after each statement in the\n\
70+
interactive interpreter. This only works on debug builds\n\
71+
-X tracemalloc: start tracing Python memory allocations using the\n\
72+
tracemalloc module. By default, only the most recent frame is stored in a\n\
73+
traceback of a trace. Use -X tracemalloc=NFRAME to start tracing with a\n\
74+
traceback limit of NFRAME frames\n\
75+
-X showalloccount: output the total count of allocated objects for each\n\
76+
type when the program finishes. This only works when Python was built with\n\
77+
COUNT_ALLOCS defined\n\
78+
-X importtime: show how long each import takes. It shows module name,\n\
79+
cumulative time (including nested imports) and self time (excluding\n\
80+
nested imports). Note that its output may be broken in multi-threaded\n\
81+
application. Typical usage is python3 -X importtime -c 'import asyncio'\n\
82+
-X dev: enable CPython’s “development mode”, introducing additional runtime\n\
83+
checks which are too expensive to be enabled by default. It will not be\n\
84+
more verbose than the default if the code is correct: new warnings are\n\
85+
only emitted when an issue is detected. Effect of the developer mode:\n\
86+
* Add default warning filter, as -W default\n\
87+
* Install debug hooks on memory allocators: see the PyMem_SetupDebugHooks() C function\n\
88+
* Enable the faulthandler module to dump the Python traceback on a crash\n\
89+
* Enable asyncio debug mode\n\
90+
* Set the dev_mode attribute of sys.flags to True\n\
91+
* io.IOBase destructor logs close() exceptions\n\
92+
-X utf8: enable UTF-8 mode for operating system interfaces, overriding the default\n\
93+
locale-aware mode. -X utf8=0 explicitly disables UTF-8 mode (even when it would\n\
94+
otherwise activate automatically). See PYTHONUTF8 for more details\n\
95+
-X pycache_prefix=PATH: enable writing .pyc files to a parallel tree rooted at the\n\
96+
given directory instead of to the code tree.\n\
6797
--check-hash-based-pycs always|default|never:\n\
6898
control how Python invalidates hash-based .pyc files\n\
6999
";

0 commit comments

Comments
 (0)