@@ -13,6 +13,7 @@ Requires: 587
13
13
Created: 28-Dec-2012
14
14
Post-History: 28-Dec-2012, 02-Jan-2013, 30-Mar-2019, 28-Jun-2020
15
15
16
+ .. highlight:: c
16
17
17
18
PEP Withdrawal
18
19
==============
@@ -151,10 +152,10 @@ Background
151
152
152
153
Over time, CPython's initialization sequence has become progressively more
153
154
complicated, offering more options, as well as performing more complex tasks
154
- (such as configuring the Unicode settings for OS interfaces in Python 3 [10_] ,
155
+ (such as configuring the Unicode settings for OS interfaces in Python 3 [10]_ ,
155
156
bootstrapping a pure Python implementation of the import system, and
156
157
implementing an isolated mode more suitable for system applications that run
157
- with elevated privileges [6_] ).
158
+ with elevated privileges [6]_ ).
158
159
159
160
Much of this complexity is formally accessible only through the ``Py_Main``
160
161
and ``Py_Initialize`` APIs, offering embedding applications little
@@ -166,9 +167,9 @@ API cannot be used safely.
166
167
A number of proposals are on the table for even *more* sophisticated
167
168
startup behaviour, such as better control over ``sys.path``
168
169
initialization (e.g. easily adding additional directories on the command line
169
- in a cross-platform fashion [7_] , controlling the configuration of
170
- ``sys.path[0]`` [8_] ), easier configuration of utilities like coverage
171
- tracing when launching Python subprocesses [9_] ).
170
+ in a cross-platform fashion [7]_ , controlling the configuration of
171
+ ``sys.path[0]`` [8]_ ), easier configuration of utilities like coverage
172
+ tracing when launching Python subprocesses [9]_ ).
172
173
173
174
Rather than continuing to bolt such behaviour onto an already complicated
174
175
system indefinitely, this PEP proposes to start simplifying the status quo by
@@ -195,7 +196,7 @@ The CPython startup sequence as of Python 3.6 was difficult to understand, and
195
196
even more difficult to modify. It was not clear what state the interpreter was
196
197
in while much of the initialization code executed, leading to behaviour such
197
198
as lists, dictionaries and Unicode values being created prior to the call
198
- to ``Py_Initialize`` when the ``-X`` or ``-W`` options are used [1_] .
199
+ to ``Py_Initialize`` when the ``-X`` or ``-W`` options are used [1]_ .
199
200
200
201
By moving to an explicitly multi-phase startup sequence, developers should
201
202
only need to understand:
@@ -238,11 +239,15 @@ should minimise their impact on the startup overhead.
238
239
Experience with the importlib migration suggests that the startup time is
239
240
dominated by IO operations. However, to monitor the impact of any changes,
240
241
a simple benchmark can be used to check how long it takes to start and then
241
- tear down the interpreter::
242
+ tear down the interpreter:
243
+
244
+ .. code-block:: bash
242
245
243
246
python3 -m timeit -s "from subprocess import call" "call(['./python', '-Sc', 'pass'])"
244
247
245
- Current numbers on my system for Python 3.7 (as built by the Fedora project)::
248
+ Current numbers on my system for Python 3.7 (as built by the Fedora project):
249
+
250
+ .. code-block:: shell
246
251
247
252
$ python3 -m timeit -s "from subprocess import call" "call(['python3', '-Sc', 'pass'])"
248
253
50 loops, best of 5: 6.48 msec per loop
@@ -269,7 +274,7 @@ Implementation Strategy
269
274
=======================
270
275
271
276
An initial attempt was made at implementing an earlier version of this PEP for
272
- Python 3.4 [2_] , with one of the significant problems encountered being merge
277
+ Python 3.4 [2]_ , with one of the significant problems encountered being merge
273
278
conflicts after the initial structural changes were put in place to start the
274
279
refactoring process. Unlike some other previous major changes, such as the
275
280
switch to an AST-based compiler in Python 2.5, or the switch to the importlib
@@ -1069,7 +1074,7 @@ aspects are the fact that user site directories are enabled,
1069
1074
environment variables are trusted and that the directory containing the
1070
1075
executed file is placed at the beginning of the import path.
1071
1076
1072
- Issue 16499 [6_] added a ``-I`` option to change the behaviour of
1077
+ Issue 16499 [6]_ added a ``-I`` option to change the behaviour of
1073
1078
the normal CPython executable, but this is a hard to discover solution (and
1074
1079
adds yet another option to an already complex CLI). This PEP proposes to
1075
1080
instead add a separate ``system-python`` executable
@@ -1173,7 +1178,7 @@ Locating Python and the standard library
1173
1178
1174
1179
The location of the Python binary and the standard library is influenced
1175
1180
by several elements. The algorithm used to perform the calculation is
1176
- not documented anywhere other than in the source code [3_,4_] . Even that
1181
+ not documented anywhere other than in the source code [3]_, [4]_ . Even that
1177
1182
description is incomplete, as it failed to be updated for the virtual
1178
1183
environment support added in Python 3.3 (detailed in :pep:`405`).
1179
1184
@@ -1213,7 +1218,7 @@ the ``PYTHONPATH`` environment variable.
1213
1218
1214
1219
The ``site`` module, which is implicitly imported at startup (unless
1215
1220
disabled via the ``-S`` option) adds additional paths to this initial
1216
- set of paths, as described in its documentation [5_] .
1221
+ set of paths, as described in its documentation [5]_ .
1217
1222
1218
1223
The ``-s`` command line option can be used to exclude the user site
1219
1224
directory from the list of directories added. Embedding applications
@@ -1372,7 +1377,7 @@ connection by the operating system.
1372
1377
TBD: Document how the "-x" option is handled (skips processing of the
1373
1378
first comment line in the main script)
1374
1379
1375
- Also see detailed sequence of operations notes at [1_]
1380
+ Also see detailed sequence of operations notes at [1]_.
1376
1381
1377
1382
1378
1383
References
0 commit comments