-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
libregrtest: Reduce number of imports at startup #111881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
tests
Tests in the Lib/test dir
Comments
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Nov 9, 2023
In most cases, doctest is not needed. So don't always import it at startup.
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Nov 9, 2023
* Import lazily getpass in test.support * Only import ctypes on Windows in test.support.os_helper.
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Nov 9, 2023
The linecache module is only used by StackSummary and FrameSummary.line property. Import the linecache module lazily to speedup Python imports and reduce the number of imports when the traceback module is imported.
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Nov 9, 2023
The linecache module is only used by StackSummary and FrameSummary.line property. Import the linecache module lazily to speedup Python imports and reduce the number of imports when the traceback module is imported.
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Nov 9, 2023
The linecache module is only used by StackSummary and FrameSummary.line property. Import the linecache module lazily to speedup Python imports and reduce the number of imports when the traceback module is imported.
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Nov 9, 2023
Use lazy imports for argparse, difflib and fnmatch imports in unittest to speedup Python startup time when running tests, and the number of imported modules when running tests.
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Nov 9, 2023
Use lazy imports for argparse, difflib and fnmatch imports in unittest to speedup Python startup time when running tests, and the number of imported modules when running tests.
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Nov 9, 2023
Use lazy imports for argparse, difflib and fnmatch imports in unittest to speedup Python startup time when running tests, and the number of imported modules when running tests.
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Nov 9, 2023
Use lazy import for difflib and linecache imports in doctest to speedup Python startup and reduce the number of imports when running tests.
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Nov 9, 2023
The random module now imports the _sha2 module laziliy in Random.seed() method for str, bytes and bytearray seeds. Lazy import makes Python startup faster and reduce the number of imported modules at startup.
vstinner
added a commit
that referenced
this issue
Nov 9, 2023
* Import lazily getpass in test.support * Only import ctypes on Windows in test.support.os_helper.
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Nov 9, 2023
* Import lazily getpass in test.support * Only import ctypes on Windows in test.support.os_helper. (cherry picked from commit 0372e3b)
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Nov 9, 2023
The random module now imports the _sha2 module lazily in the Random.seed() method for str, bytes and bytearray seeds. It also imports lazily the warnings module in the _randbelow() method for classes without getrandbits(). Lazy import makes Python startup faster and reduces the number of imported modules at startup.
vstinner
added a commit
that referenced
this issue
Nov 9, 2023
In most cases, doctest is not needed. So don't always import it at startup. The change reduces the number of modules already imported when a test is run.
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Nov 9, 2023
In most cases, doctest is not needed. So don't always import it at startup. The change reduces the number of modules already imported when a test is run. (cherry picked from commit 6f09f69) Co-authored-by: Victor Stinner <[email protected]>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Nov 9, 2023
In most cases, doctest is not needed. So don't always import it at startup. The change reduces the number of modules already imported when a test is run. (cherry picked from commit 6f09f69) Co-authored-by: Victor Stinner <[email protected]>
vstinner
added a commit
that referenced
this issue
Nov 9, 2023
vstinner
added a commit
that referenced
this issue
Nov 9, 2023
…111894) gh-111881: Import doctest lazily in libregrtest (GH-111884) In most cases, doctest is not needed. So don't always import it at startup. The change reduces the number of modules already imported when a test is run. (cherry picked from commit 6f09f69) Co-authored-by: Victor Stinner <[email protected]>
vstinner
added a commit
that referenced
this issue
Nov 9, 2023
…111893) gh-111881: Import doctest lazily in libregrtest (GH-111884) In most cases, doctest is not needed. So don't always import it at startup. The change reduces the number of modules already imported when a test is run. (cherry picked from commit 6f09f69) Co-authored-by: Victor Stinner <[email protected]>
vstinner
added a commit
that referenced
this issue
Nov 9, 2023
The random module now imports the _sha2 module lazily in the Random.seed() method for str, bytes and bytearray seeds. It also imports lazily the warnings module in the _randbelow() method for classes without getrandbits(). Lazy import makes Python startup faster and reduces the number of imported modules at startup.
May I work on this issue? would love to take a crack at it. |
Yes, you can review proposed PRs and help to get them merged. |
vstinner
added a commit
to vstinner/cpython
that referenced
this issue
Nov 16, 2023
It allows running the test suite when the zlib extension is missing.
vstinner
added a commit
that referenced
this issue
Nov 16, 2023
It allows running the test suite when the zlib extension is missing.
I lost track of this change, so I just close it. |
aisk
pushed a commit
to aisk/cpython
that referenced
this issue
Feb 11, 2024
* Import lazily getpass in test.support * Only import ctypes on Windows in test.support.os_helper.
aisk
pushed a commit
to aisk/cpython
that referenced
this issue
Feb 11, 2024
In most cases, doctest is not needed. So don't always import it at startup. The change reduces the number of modules already imported when a test is run.
aisk
pushed a commit
to aisk/cpython
that referenced
this issue
Feb 11, 2024
The random module now imports the _sha2 module lazily in the Random.seed() method for str, bytes and bytearray seeds. It also imports lazily the warnings module in the _randbelow() method for classes without getrandbits(). Lazy import makes Python startup faster and reduces the number of imported modules at startup.
aisk
pushed a commit
to aisk/cpython
that referenced
this issue
Feb 11, 2024
…on#112172) It allows running the test suite when the zlib extension is missing.
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this issue
Sep 2, 2024
* Import lazily getpass in test.support * Only import ctypes on Windows in test.support.os_helper.
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this issue
Sep 2, 2024
In most cases, doctest is not needed. So don't always import it at startup. The change reduces the number of modules already imported when a test is run.
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this issue
Sep 2, 2024
The random module now imports the _sha2 module lazily in the Random.seed() method for str, bytes and bytearray seeds. It also imports lazily the warnings module in the _randbelow() method for classes without getrandbits(). Lazy import makes Python startup faster and reduces the number of imported modules at startup.
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this issue
Sep 2, 2024
…on#112172) It allows running the test suite when the zlib extension is missing.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, when a test is run by
./python -m test (...)
, the test starts with 170 modules already imported. The problem is that imports can have side effects and I would prefer to start tests in a "minimal environment".Running a test with
./python -m test (...)
only imports 164 modules.Example by adding
Lib/test/test_x.py
:Output:
I propose to try to make more imports lazy: only import the module the first time that it's needed, tests are rarely "performance sensitive". It may improve the "startup time".
Linked PRs
The text was updated successfully, but these errors were encountered: