bpo-33944: note about the intended use of code in .pth files (GH-1013… · python/cpython@d1d968d (original) (raw)
File tree
2 files changed
lines changed
- Misc/NEWS.d/next/Documentation
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -61,6 +61,19 @@ directory rather than a file. No item is added to ``sys.path`` more than | ||
61 | 61 | once. Blank lines and lines beginning with ``#`` are skipped. Lines starting |
62 | 62 | with ``import`` (followed by space or tab) are executed. |
63 | 63 | |
64 | +.. note:: | |
65 | + | |
66 | + An executable line in a :file:`.pth` file is run at every Python startup, | |
67 | + regardless of whether a particular module is actually going to be used. | |
68 | + Its impact should thus be kept to a minimum. | |
69 | + The primary intended purpose of executable lines is to make the | |
70 | + corresponding module(s) importable | |
71 | + (load 3rd-party import hooks, adjust :envvar:`PATH` etc). | |
72 | + Any other initialization is supposed to be done upon a module's | |
73 | + actual import, if and when it happens. | |
74 | + Limiting a code chunk to a single line is a deliberate measure | |
75 | + to discourage putting anything more complex here. | |
76 | + | |
64 | 77 | .. index:: |
65 | 78 | single: package |
66 | 79 | triple: path; configuration; file |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 | +Added a note about the intended use of code in .pth files. |