gh-118761: Improve import time of subprocess#129427
Conversation
gpshead
left a comment
There was a problem hiding this comment.
thanks for including the comments in the code as to why. as much as a dislike it from a style perspective, this is the right way to get faster import times in Python today.
* subprocess: lazy import signal and locale to improve module import time (cherry picked from commit 49f2465) Co-authored-by: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com>
|
GH-129447 is a backport of this pull request to the 3.13 branch. |
* subprocess: lazy import signal and locale to improve module import time (cherry picked from commit 49f2465) Co-authored-by: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com>
|
GH-129448 is a backport of this pull request to the 3.12 branch. |
|
|
|
The iOS test failure is weird - yes, it failed in a stress test... but it then passed on a re-run. Not sure why it's reported as a fail (and a fail without identifying the failing test...) It doesn't look like a problem though. |
* subprocess: lazy import signal and locale to improve module import time
…H-129427)" This reverts commit 49f2465. This caused bugs in the `__del__` finalizer: python#118761 (comment)
…130201) * Revert "gh-118761: Improve import time of `subprocess` (GH-129427)" This reverts commit 49f2465. Also known as f502c8f in 3.13 (PR #129447) Also known as f65aa0d in 3.12 (PR #129448) This caused bugs in the `__del__` finalizer: #118761 (comment) --------- Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
…H-129427)" (pythonGH-130201) * Revert "pythongh-118761: Improve import time of `subprocess` (pythonGH-129427)" This reverts commit 49f2465. Also known as f502c8f in 3.13 (PR pythonGH-129447) Also known as f65aa0d in 3.12 (PR pythonGH-129448) This caused bugs in the `__del__` finalizer: python#118761 (comment) --------- (cherry picked from commit ae30646) Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
…H-129427)" (pythonGH-130201) * Revert "pythongh-118761: Improve import time of `subprocess` (pythonGH-129427)" This reverts commit 49f2465. Also known as f502c8f in 3.13 (PR pythonGH-129447) Also known as f65aa0d in 3.12 (PR pythonGH-129448) This caused bugs in the `__del__` finalizer: python#118761 (comment) --------- (cherry picked from commit ae30646) Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
)" (GH-130201) (#130205) gh-118761: Revert "Improve import time of `subprocess` (GH-129427)" (GH-130201) * Revert "gh-118761: Improve import time of `subprocess` (GH-129427)" This reverts commit 49f2465. Also known as f502c8f in 3.13 (PR GH-129447) Also known as f65aa0d in 3.12 (PR GH-129448) This caused bugs in the `__del__` finalizer: #118761 (comment) --------- (cherry picked from commit ae30646) Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
)" (GH-130201) (#130204) gh-118761: Revert "Improve import time of `subprocess` (GH-129427)" (GH-130201) * Revert "gh-118761: Improve import time of `subprocess` (GH-129427)" This reverts commit 49f2465. Also known as f502c8f in 3.13 (PR GH-129447) Also known as f65aa0d in 3.12 (PR GH-129448) This caused bugs in the `__del__` finalizer: #118761 (comment) --------- (cherry picked from commit ae30646) Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This makes
import subprocesslazy importlocaleandsignal. As a result, alsore(imported bylocale) andenum(imported bysignal) imports are skipped.Benchmark import time
mainbranchPR branch
Benchmark
subprocess.runcallIn fact, this not only has an effect on import time, but simple
subprocess.runcalls, too:mainbranchPR branch