Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6690bb9f
Commit
6690bb9f
authored
Jan 20, 2018
by
INADA Naoki
Committed by
GitHub
Jan 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-32596: Lazy import concurrent.futures.process and thread (GH-5241)
parent
338cd83c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
Lib/concurrent/futures/__init__.py
Lib/concurrent/futures/__init__.py
+33
-2
Misc/NEWS.d/next/Library/2018-01-19-19-57-45.bpo-32596.4aVIie.rst
...S.d/next/Library/2018-01-19-19-57-45.bpo-32596.4aVIie.rst
+4
-0
No files found.
Lib/concurrent/futures/__init__.py
View file @
6690bb9f
...
...
@@ -15,5 +15,36 @@ from concurrent.futures._base import (FIRST_COMPLETED,
Executor
,
wait
,
as_completed
)
from
concurrent.futures.process
import
ProcessPoolExecutor
from
concurrent.futures.thread
import
ThreadPoolExecutor
__all__
=
(
'FIRST_COMPLETED'
,
'FIRST_EXCEPTION'
,
'ALL_COMPLETED'
,
'CancelledError'
,
'TimeoutError'
,
'BrokenExecutor'
,
'Future'
,
'Executor'
,
'wait'
,
'as_completed'
,
'ProcessPoolExecutor'
,
'ThreadPoolExecutor'
,
)
def
__dir__
():
return
__all__
+
(
'__author__'
,
'__doc__'
)
def
__getattr__
(
name
):
global
ProcessPoolExecutor
,
ThreadPoolExecutor
if
name
==
'ProcessPoolExecutor'
:
from
.process
import
ProcessPoolExecutor
return
ProcessPoolExecutor
if
name
==
'ThreadPoolExecutor'
:
from
.thread
import
ThreadPoolExecutor
return
ThreadPoolExecutor
raise
AttributeError
(
f"module
{
__name__
}
has no attribute
{
name
}
"
)
Misc/NEWS.d/next/Library/2018-01-19-19-57-45.bpo-32596.4aVIie.rst
0 → 100644
View file @
6690bb9f
``concurrent.futures`` imports ``ThreadPoolExecutor`` and
``ProcessPoolExecutor`` lazily (using :pep:`562`).
It makes ``import asyncio`` about 15% faster because asyncio
uses only ``ThreadPoolExecutor`` by default.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment