Skip to content

Instantly share code, notes, and snippets.

@ericsnowcurrently
Last active January 7, 2025 20:30
Show Gist options
  • Save ericsnowcurrently/33cb019fc01142a6610912ddbdc196ca to your computer and use it in GitHub Desktop.
Save ericsnowcurrently/33cb019fc01142a6610912ddbdc196ca to your computer and use it in GitHub Desktop.
Analysis of Pyconfig

PyConfig API

most relevant:

  • PyConfig (struct)
  • Py_InitializeFromConfig()
  • PyInterpreterState.config
  • _PyInterpreterState_GetConfig()
  • _Py_GetMainConfig()

PyConfig Fields

legend:

X - read + - written

field type main init
fini
after env var CLI
isolated int
use_environment int
dev_mode int
install_signal_handlers int
use_hash_seed int
hash_seed unsigned long
faulthandler int
tracemalloc int
perf_profiling int
import_time int
code_debug_ranges int
show_ref_count int
dump_refs int
dump_refs_file wchar_t *
malloc_stats int
filesystem_encoding wchar_t *
filesystem_errors wchar_t *
pycache_prefix wchar_t *
parse_argv int
orig_argv PyWideStringList
argv PyWideStringList
xoptions PyWideStringList
warnoptions PyWideStringList
site_import int
bytes_warning int
warn_default_encoding int
inspect int
interactive int
optimization_level int
parser_debug int
write_bytecode int
verbose int
quiet int
user_site_directory int
configure_c_stdio int
buffered_stdio int
stdio_encoding wchar_t *
stdio_errors wchar_t *
check_hash_pycs_mode wchar_t *
use_frozen_modules int
safe_path int
int_max_str_digits int
cpu_count int
skip_source_first_line int X
sys_path_0 wchar_t * X+

Path configuration inputs:

field type main init after env var CLI
pathconfig_warnings int
program_name wchar_t *
pythonpath_env wchar_t *
home wchar_t *
platlibdir wchar_t *

Path configuration outputs:

field type main init after env var CLI
module_search_paths_set int
module_search_paths PyWideStringList
stdlib_dir wchar_t *
executable wchar_t *
base_executable wchar_t *
prefix wchar_t *
base_prefix wchar_t *
exec_prefix wchar_t *
base_exec_prefix wchar_t *

Only used by Py_Main():

field type main init after env var CLI
run_command wchar_t * X
run_module wchar_t * X
run_filename wchar_t * X

#ifdef Py_DEBUG:

field type main init after env var CLI
run_presite wchar_t *

#ifdef MS_WINDOWS:

field type main init after env var CLI
legacy_windows_stdio int
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment