File tree Expand file tree Collapse file tree 7 files changed +29
-16
lines changed
NEWS.d/next/Core_and_Builtins Expand file tree Collapse file tree 7 files changed +29
-16
lines changed Original file line number Diff line number Diff 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.
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -966,6 +966,7 @@ Beomsoo Bombs Kim
966966Derek D. Kim
967967Gihwan Kim
968968Jan Kim
969+ Noah Kim
969970Taek Joo Kim
970971Yeojin Kim
971972Sam Kimbrel
Original file line number Diff line number Diff line change 11:option: `-X importtime <-X> ` now accepts value ``2 ``, which indicates that
22an ``importtime `` entry should also be printed if an imported module has
33already been loaded.
4+ Patch by Noah Kim and Adam Turner.
Original file line number Diff line number Diff line change @@ -344,6 +344,10 @@ Set implementation-specific option. The following options are available:
344344 application. Typical usage is
345345 \fB python3 \- 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+ \fB cached \fR will be printed in both time columns.
350+
347351 \fB \- X faulthandler \fR : enable faulthandler
348352
349353 \fB \- X frozen_modules= \fR [\fB on \fR |\fB off \fR ]: whether or not frozen modules
@@ -648,9 +652,10 @@ See also the \fB\-X perf\fR option.
648652.IP PYTHONPLATLIBDIR
649653Override 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 \fB 1 \fR , Python will show
656+ how long each import takes. If set to \fB 2 \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
655660If this is set, Python will write \fB .pyc \fR files in a mirror directory tree
656661at this path, instead of in \fB __pycache__ \fR directories within the source
Original file line number Diff line number Diff 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\
You can’t perform that action at this time.
0 commit comments