mirror of
https://github.com/python/cpython.git
synced 2026-04-13 15:20:52 +00:00
gh-117865: Speedup import of inspect module (#144756)
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
This commit is contained in:
parent
46c5c57226
commit
ea90b032a0
3 changed files with 14 additions and 4 deletions
|
|
@ -153,9 +153,9 @@
|
|||
import itertools
|
||||
import linecache
|
||||
import os
|
||||
import re
|
||||
lazy import re
|
||||
import sys
|
||||
import tokenize
|
||||
lazy import tokenize
|
||||
import token
|
||||
import types
|
||||
import functools
|
||||
|
|
@ -163,9 +163,9 @@
|
|||
from keyword import iskeyword
|
||||
from operator import attrgetter
|
||||
from collections import namedtuple, OrderedDict
|
||||
from weakref import ref as make_weakref
|
||||
from _weakref import ref as make_weakref
|
||||
|
||||
# Create constants for the compiler flags in Include/code.h
|
||||
# Create constants for the compiler flags in Include/cpython/code.h
|
||||
# We try to get them from dis to avoid duplication
|
||||
mod_dict = globals()
|
||||
for k, v in dis.COMPILER_FLAG_NAMES.items():
|
||||
|
|
|
|||
|
|
@ -173,6 +173,15 @@ def __get__(self, instance, owner):
|
|||
return self.func.__get__(instance, owner)
|
||||
|
||||
|
||||
class TestImportTime(unittest.TestCase):
|
||||
|
||||
@cpython_only
|
||||
def test_lazy_import(self):
|
||||
import_helper.ensure_lazy_imports(
|
||||
"inspect", {"re", "tokenize"}
|
||||
)
|
||||
|
||||
|
||||
class TestPredicates(IsTestBase):
|
||||
|
||||
def test_excluding_predicates(self):
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Reduce the import time of :mod:`inspect` module by ~20%.
|
||||
Loading…
Add table
Add a link
Reference in a new issue