bpo-31415: Support PYTHONPROFILEIMPORTTIME envvar equivalent to -X im… · python/cpython@700d2e4

Original file line numberDiff line numberDiff line change

@@ -411,7 +411,8 @@ Miscellaneous options

411411

* ``-X importtime`` to show how long each import takes. It shows module name,

412412

cumulative time (including nested imports) and self time (exluding nested

413413

imports). Note that its output may be broken in multi threaded application.

414-

Typical usage is ``python3 -X importtime -c 'import asyncio'``.

414+

Typical usage is ``python3 -X importtime -c 'import asyncio'``. See also

415+

:envvar:`PYTHONPROFILEIMPORTTIME`.

415416
416417

It also allows passing arbitrary values and retrieving them through the

417418

:data:`sys._xoptions` dictionary.

@@ -429,7 +430,7 @@ Miscellaneous options

429430

The ``-X showalloccount`` option.

430431
431432

.. versionadded:: 3.7

432-

The ``-X importtime`` option.

433+

The ``-X importtime`` and :envvar:`PYTHONPROFILEIMPORTTIME` options.

433434
434435
435436

Options you shouldn't use

@@ -650,6 +651,15 @@ conflict.

650651

.. versionadded:: 3.4

651652
652653
654+

.. envvar:: PYTHONPROFILEIMPORTTIME

655+
656+

If this environment variable is set to a non-empty string, Python will

657+

show how long each import takes. This is exactly equivalent to setting

658+

``-X importtime`` on the command line.

659+
660+

.. versionadded:: 3.7

661+
662+
653663

.. envvar:: PYTHONASYNCIODEBUG

654664
655665

If this environment variable is set to a non-empty string, enable the