Python Initialization Configuration — Python 3.16.0a0 documentation

docs.python.org

Tin mới

Profiling and tracing

Python Module Index

3.16.0a0 Documentation

Python/C API reference manual

PyInitConfig C API¶

Python can be initialized with Py_InitializeFromInitConfig().

Python Development Mode

Example of customized Python always running with the Python Development Mode enabled; return -1 on error:

PyImport_AppendInittab()

Add a built-in extension module to the table of built-in modules.

sys: Access system-specific parameters and functions.

At runtime, it’s possible to get and set configuration options using PyConfig_Get() and PyConfig_Set() functions.

attached thread state

Get the current runtime value of a configuration option as a Python object.

default memory allocators

PYMEM_ALLOCATOR_DEFAULT (1): default memory allocators.

configured using --without-pymalloc

PYMEM_ALLOCATOR_NOT_SET (0): don’t change memory allocators (use defaults).

PYTHONLEGACYWINDOWSFSENCODING

Initialized from the PYTHONLEGACYWINDOWSFSENCODING environment variable value.

Preinitialize Python with PyPreConfig¶

Set the Python memory allocators (PyPreConfig.allocator)

Preinitialize Python with PyPreConfig¶

Set the Python memory allocators (PyPreConfig.allocator)

Opt-in EncodingWarning

If non-zero, emit a EncodingWarning warning when io.TextIOWrapper uses its default encoding. See Opt-in EncodingWarning for details.

faulthandler.enable()

If non-zero, call faulthandler.enable() at startup.

integer string conversion length limitation

Configures the integer string conversion length limitation. An initial value of -1 means the value will be taken from the command line or environment or otherwise default to 4300 (sys.int_info.default_max_str_digits). A

multiprocessing.cpu_count()

If the value of cpu_count is not -1 then it will override the return values of os.cpu_count(), os.process_cpu_count(), and multiprocessing.cpu_count().

readline: GNU readline support for Python.

Python REPL doesn’t import readline nor enable default readline configuration on interactive prompts.

site: Module responsible for site-specific configuration.

module or module:func entry point that should be executed before the site module is imported.

tracemalloc.start()

Set by -X tracemalloc=N command line option and by the PYTHONTRACEMALLOC environment variable.

Python support for the perf map compatible profilers

See Python support for the perf map compatible profilers for more information.

warnings: Issue warning messages and control their disposition.

Options of the warnings module to build warnings filters, lowest to highest priority: sys.warnoptions.

Virtual Environments

PyConfig contains multiple fields for the path configuration:

importlib: The implementation of the import machinery.