Issue #19205: Don't import the 're' module in site and sysconfig module to

to speed up interpreter start.
This commit is contained in:
Christian Heimes 2013-10-12 00:24:55 +02:00
parent fd4722cacf
commit 8c9cd5a3d4
4 changed files with 24 additions and 4 deletions

View file

@ -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()