summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorINADA Naoki <methane@users.noreply.github.com>2018-01-27 01:10:06 (GMT)
committerGitHub <noreply@github.com>2018-01-27 01:10:06 (GMT)
commit37420deb80dcf0fc41a728838b0340b93ca01d90 (patch)
tree83a3750f4d1b9edd204a648046f85d28cebe9f41 /Lib/inspect.py
parent29a7df78277447cf6b898dfa0b1b42f8da7abc0c (diff)
downloadcpython-37420deb80dcf0fc41a728838b0340b93ca01d90.zip
cpython-37420deb80dcf0fc41a728838b0340b93ca01d90.tar.gz
cpython-37420deb80dcf0fc41a728838b0340b93ca01d90.tar.bz2
bpo-32678: inspect: Import ast lazily (GH-5344)
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index b755187..bc97efe 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -32,7 +32,6 @@ __author__ = ('Ka-Ping Yee <ping@lfw.org>',
'Yury Selivanov <yselivanov@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