[Python-checkins] bpo-32678: inspect: Import ast lazily (GH-5344)
INADA Naoki
webhook-mailer at python.org
Fri Jan 26 20:10:10 EST 2018
https://github.com/python/cpython/commit/37420deb80dcf0fc41a728838b0340b93ca01d90
commit: 37420deb80dcf0fc41a728838b0340b93ca01d90
branch: master
author: INADA Naoki <methane at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-01-27T10:10:06+09:00
summary:
bpo-32678: inspect: Import ast lazily (GH-5344)
files:
M Lib/inspect.py
diff --git a/Lib/inspect.py b/Lib/inspect.py
index b7551878b74..bc97efe179c 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -32,7 +32,6 @@
'Yury Selivanov <yselivanov at sprymix.com>')
import abc
-import ast
import dis
import collections.abc
import enum
@@ -1940,6 +1939,9 @@ def _signature_fromstr(cls, obj, s, skip_bound_arg=True):
"""Private helper to parse content of '__text_signature__'
and return a Signature based on it.
"""
+ # Lazy import ast because it's relatively heavy and
+ # it's not used for other than this function.
+ import ast
Parameter = cls._parameter_cls
More information about the Python-checkins
mailing list