mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #19205: Don't import the 're' module in site and sysconfig module to
to speed up interpreter start.
This commit is contained in:
parent
fd4722cacf
commit
8c9cd5a3d4
4 changed files with 24 additions and 4 deletions
|
@ -420,5 +420,20 @@ class ImportSideEffectTests(unittest.TestCase):
|
|||
self.assertEqual(code, 200, msg="Can't find " + url)
|
||||
|
||||
|
||||
class StartupImportTests(unittest.TestCase):
|
||||
|
||||
def test_startup_imports(self):
|
||||
# This tests checks which modules are loaded by Python when it
|
||||
# initially starts upon startup.
|
||||
args = [sys.executable, '-I', '-c',
|
||||
'import sys; print(set(sys.modules))']
|
||||
stdout = subprocess.check_output(args)
|
||||
modules = eval(stdout.decode('utf-8'))
|
||||
self.assertIn('site', modules)
|
||||
|
||||
re_mods = {'re', '_sre', 'sre_compile', 'sre_constants', 'sre_parse'}
|
||||
self.assertFalse(modules.intersection(re_mods))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue