@@ -539,11 +539,21 @@ Miscellaneous options
539539 * ``-X importtime `` to show how long each import takes. It shows module
540540 name, cumulative time (including nested imports) and self time (excluding
541541 nested imports). Note that its output may be broken in multi-threaded
542- application. Typical usage is ``python3 -X importtime -c 'import
543- asyncio' ``. See also :envvar: `PYTHONPROFILEIMPORTTIME `.
542+ application. Typical usage is ``python -X importtime -c 'import asyncio' ``.
543+
544+ ``-X importtime=2 `` enables additional output that indicates when an
545+ imported module has already been loaded. In such cases, the string
546+ ``cached `` will be printed in both time columns.
547+
548+ See also :envvar: `PYTHONPROFILEIMPORTTIME `.
544549
545550 .. versionadded :: 3.7
546551
552+ .. versionchanged :: next
553+
554+ Added ``-X importtime=2 `` to also trace imports of loaded modules,
555+ and reserved values other than ``1 `` and ``2 `` for future use.
556+
547557 * ``-X dev ``: enable :ref: `Python Development Mode <devmode >`, introducing
548558 additional runtime checks that are too expensive to be enabled by
549559 default. See also :envvar: `PYTHONDEVMODE `.
@@ -982,12 +992,17 @@ conflict.
982992
983993.. envvar :: PYTHONPROFILEIMPORTTIME
984994
985- If this environment variable is set to a non-empty string, Python will
986- show how long each import takes.
995+ If this environment variable is set to ``1 ``, Python will show
996+ how long each import takes. If set to ``2 ``, Python will include output for
997+ imported modules that have already been loaded.
987998 This is equivalent to setting the :option: `-X ` ``importtime `` option.
988999
9891000 .. versionadded :: 3.7
9901001
1002+ .. versionchanged :: next
1003+
1004+ Added ``PYTHONPROFILEIMPORTTIME=2 `` to also trace imports of loaded modules.
1005+
9911006
9921007.. envvar :: PYTHONASYNCIODEBUG
9931008
0 commit comments