为什么模块在Python 3中的导入速度要慢得多,并且有一种解决方法?

Dun*_*eal 5 python performance python-2.7 python-3.x

与Python 2相比,在Python 3中导入某些模块要花费更长的时间。

$ t python2 -c 'import requests'
0m0.174s
$ t python3 -c 'import requests'
0m0.403s
$ t python2 -c 'import bs4'
0m0.256s
$ t python3 -c 'import bs4'
0m0.431s
Run Code Online (Sandbox Code Playgroud)

由于我的某些项目同时导入了两个模块以及更多模块,因此我收到了注意到延迟的用户的抱怨,这些延迟总计超过一秒钟。

上面的基准是Python 2.7.15rc1和Python 3.6.7-Ubuntu 18.04 LTS上的最新系统Python,因此非常受欢迎。

知道是什么原因导致新版Python出现这种延迟,以及如何缓解此问题?