This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Lazy import ast in inspect
Type: resource usage Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: methane
Priority: normal Keywords: patch

Created on 2018-01-26 12:30 by methane, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 5344 merged methane, 2018-01-26 12:32
Messages (2)
msg310759 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-01-26 12:30
inspect imports ast but it's used only for creating signature.

But asyncio uses inspect module for unwrap(), isgenerator(), etc...
And ast module is relatively heavy for import.

This is output of python -Ximporttime -c 'import asyncio':

import time:       147 |        147 |     asyncio.constants
import time:      1456 |       1456 |           _ast
import time:       363 |       1818 |         ast
...
import time:      1890 |       5152 |       inspect
...
import time:       303 |       5984 |     asyncio.coroutines
...
import time:       731 |      37941 |   asyncio.base_events
...
import time:       375 |      41383 | asyncio
msg310826 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-01-27 01:10
New changeset 37420deb80dcf0fc41a728838b0340b93ca01d90 by INADA Naoki in branch 'master':
bpo-32678: inspect: Import ast lazily (GH-5344)
https://github.com/python/cpython/commit/37420deb80dcf0fc41a728838b0340b93ca01d90
History
Date User Action Args
2022-04-11 14:58:57adminsetgithub: 76859
2018-01-27 01:10:36methanesetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-01-27 01:10:10methanesetmessages: + msg310826
2018-01-26 12:32:52methanesetkeywords: + patch
stage: patch review
pull_requests: + pull_request5191
2018-01-26 12:30:50methanecreate