Skip to content

Commit f9c07ce

Browse files
committed
Documentation
1 parent 0b0c56d commit f9c07ce

File tree

7 files changed

+29
-16
lines changed

7 files changed

+29
-16
lines changed

Doc/c-api/init_config.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ Configuration Options
363363
- Read-only
364364
* - ``"import_time"``
365365
- :c:member:`import_time <PyConfig.import_time>`
366-
- ``bool``
366+
- ``int``
367367
- Read-only
368368
* - ``"inspect"``
369369
- :c:member:`inspect <PyConfig.inspect>`
@@ -1477,14 +1477,19 @@ PyConfig
14771477
14781478
.. c:member:: int import_time
14791479
1480-
If non-zero, profile import time. If ``2``, include additional output that
1481-
indicates when an imported module has already been loaded.
1480+
If ``1``, profile import time.
1481+
If ``2``, include additional output that indicates
1482+
when an imported module has already been loaded.
14821483
14831484
Set by the :option:`-X importtime <-X>` option and the
14841485
:envvar:`PYTHONPROFILEIMPORTTIME` environment variable.
14851486
14861487
Default: ``0``.
14871488
1489+
.. versionchanged:: next
1490+
1491+
Added support for ``import_time = 2``
1492+
14881493
.. c:member:: int inspect
14891494
14901495
Enter interactive mode after executing a script or a command.

Doc/using/cmdline.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,13 @@ 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'``.
544543

545544
``-X importtime=2`` enables additional output that indicates when an
546545
imported module has already been loaded. In such cases, the string
547-
``cached`` will be printed in the self time and cumulative time columns.
546+
``cached`` will be printed in both time columns.
547+
548+
See also :envvar:`PYTHONPROFILEIMPORTTIME`.
548549

549550
.. versionadded:: 3.7
550551

Doc/whatsnew/3.14.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -626,12 +626,12 @@ Other language changes
626626
of HMAC is not available.
627627
(Contributed by Bénédikt Tran in :gh:`99108`.)
628628

629-
* :option:`-X importtime <-X>` now accepts value ``2``, which indicates that
630-
an ``importtime`` entry should also be printed if an imported module has
631-
already been loaded. The ``self`` and ``cumulative`` times for such entries
629+
* The import time flag can now track modules that are already loaded ('cached'),
630+
via the new :option:`-X importtime=2 <-X>`.
631+
When such a module is imported, the ``self`` and ``cumulative`` times
632632
are replaced by the string ``cached``.
633-
Values above ``2`` are now reserved for future use.
634-
(Contributed by Noah Kim in :gh:`118655`.)
633+
Values above ``2`` for ``-X importtime`` are now reserved for future use.
634+
(Contributed by Noah Kim and Adam Turner in :gh:`118655`.)
635635

636636
* When subclassing from a pure C type, the C slots for the new type are no
637637
longer replaced with a wrapped version on class creation if they are not

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,7 @@ Beomsoo Bombs Kim
966966
Derek D. Kim
967967
Gihwan Kim
968968
Jan Kim
969+
Noah Kim
969970
Taek Joo Kim
970971
Yeojin Kim
971972
Sam Kimbrel
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
:option:`-X importtime <-X>` now accepts value ``2``, which indicates that
22
an ``importtime`` entry should also be printed if an imported module has
33
already been loaded.
4+
Patch by Noah Kim and Adam Turner.

Misc/python.man

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,10 @@ Set implementation-specific option. The following options are available:
344344
application. Typical usage is
345345
\fBpython3 \-X importtime \-c 'import asyncio'\fR
346346

347+
\fB\-X importtime=2\fR enables additional output that indicates when an
348+
imported module has already been loaded. In such cases, the string
349+
\fBcached\fR will be printed in both time columns.
350+
347351
\fB\-X faulthandler\fR: enable faulthandler
348352

349353
\fB\-X frozen_modules=\fR[\fBon\fR|\fBoff\fR]: whether or not frozen modules
@@ -648,9 +652,10 @@ See also the \fB\-X perf\fR option.
648652
.IP PYTHONPLATLIBDIR
649653
Override sys.platlibdir.
650654
.IP PYTHONPROFILEIMPORTTIME
651-
If this environment variable is set to a non-empty string, Python will
652-
show how long each import takes. This is exactly equivalent to setting
653-
\fB\-X importtime\fP on the command line.
655+
If this environment variable is set to \fB1\fR, Python will show
656+
how long each import takes. If set to \fB2\fR, Python will include output for
657+
imported modules that have already been loaded.
658+
This is exactly equivalent to setting \fB\-X importtime\fP on the command line.
654659
.IP PYTHONPYCACHEPREFIX
655660
If this is set, Python will write \fB.pyc\fR files in a mirror directory tree
656661
at this path, instead of in \fB__pycache__\fR directories within the source

Python/initconfig.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ The following implementation-specific options are available:\n\
312312
"-X gil=[0|1]: enable (1) or disable (0) the GIL; also PYTHON_GIL\n"
313313
#endif
314314
"\
315-
-X importtime[=2]: show how long each import takes; -X importtime=2 also prints\
316-
rows for imports of already-loaded modules; also PYTHONPROFILEIMPORTTIME\n\
315+
-X importtime[=2]: show how long each import takes; use -X importtime=2 to\
316+
log imports of already-loaded modules; also PYTHONPROFILEIMPORTTIME\n\
317317
-X int_max_str_digits=N: limit the size of int<->str conversions;\n\
318318
0 disables the limit; also PYTHONINTMAXSTRDIGITS\n\
319319
-X no_debug_ranges: don't include extra location information in code objects;\n\

0 commit comments

Comments
 (0)