Title: Lazy import concurrent.futures.process and thread
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: inada.naoki, levkivskyi, yselivanov
Priority: normal Keywords: patch

Created on 2018-01-19 10:54 by inada.naoki, last changed 2018-01-26 01:53 by inada.naoki. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 5241 merged inada.naoki, 2018-01-19 11:00
PR 5316 merged inada.naoki, 2018-01-25 11:56
Messages (3)
msg310272 - (view) Author: Inada Naoki (inada.naoki) * (Python committer) Date: 2018-01-19 10:54
Since PEP 562 is implemented, we can use lazy imports easily.

Asyncio uses concurrent.futures.Future and concurrent.futures.ThreadPoolExecutor,
but not concurrent.futures.ProcessPoolExecutor by default.

Since importing concurrent.futures.process is slow, I want to import it lazily.
And it make sense to import concurrent.futures.thread too, because it's very
easy when we start to use __getattr__ once.

Here is quick benchmark:

$ ./python -m perf command ./python -c 'import asyncio'  # patched
command: Mean +- std dev: 60.5 ms +- 0.1 ms
$ git stash
$ ./python -m perf command ./python -c 'import asyncio'  # original
command: Mean +- std dev: 74.3 ms +- 0.2 ms
msg310310 - (view) Author: Inada Naoki (inada.naoki) * (Python committer) Date: 2018-01-20 00:54
New changeset 6690bb9f17d34eb3dec0aca8919d8d27d6c3c452 by INADA Naoki in branch 'master':
bpo-32596: Lazy import concurrent.futures.process and thread (GH-5241)
msg310725 - (view) Author: Inada Naoki (inada.naoki) * (Python committer) Date: 2018-01-26 01:53
New changeset 4666ec597c38eea06a22bcfb4157d92a0abf891c by INADA Naoki in branch 'master':
bpo-32596: Make lazy-load portable (GH-5316)
Date User Action Args
2018-01-26 01:53:35inada.naokisetmessages: + msg310725
2018-01-25 11:56:46inada.naokisetpull_requests: + pull_request5162
2018-01-20 03:47:37inada.naokisetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-01-20 00:54:44inada.naokisetmessages: + msg310310
2018-01-19 11:00:48inada.naokisetkeywords: + patch
stage: patch review
pull_requests: + pull_request5087
2018-01-19 10:54:10inada.naokicreate