python 在调试器中 运行 时导入需要很长时间
python import takes very long when run in debugger
我正在使用 https://github.com/DuyguA/DEMorphy。
我 运行 使用 python3.7 解释器编写以下代码。
import time
start = time.time()
from demorphy import Analyzer
end = time.time()
print(end-start)
输出为
0.46335792541503906
当 运行 使用 Pycharm 调试器时,输出是
/home/user/virtualenvs/demorphy_test/bin/python3 /home/user/programs/pycharm-community-2019.2.1/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 57954 --file /home/user/demorphy_test/test.py
713.0500545501709
当 运行 使用 Visual Studio 代码调试器时,输出是
/home/user/virtualenvs/ptdev/bin/python /home/user/.vscode/extensions/ms-python.python-2019.10.41019/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 42604 /home/user/demorphy_test/test.py
693.3676333427429
Terminated
当 运行 使用 Eclipse Pydev 调试器时,输出是
pydev debugger: starting (pid: 26462)
706.7083044052124
为什么使用调试器 运行 时导入语句需要这么长时间?
我怎样才能让它 运行 更快?
需要安装demorphy依赖的dawg库https://github.com/pytries/DAWG/issues/31
由于 Python 调试器的工作方式和导入方式,它很慢。在 Python 中导入实际上是在执行模块中的代码。在调试器下执行代码本来就比较慢,因为执行的每一步都必须通过调试器以查看是否运行正常。命中断点。
加快调试速度的唯一方法是提高调试器的速度(VS Code 的 Python 扩展正在考虑引入一些调试器速度改进,但尚无时间表最初它们只会用于 Python 3.7).
我正在使用 https://github.com/DuyguA/DEMorphy。 我 运行 使用 python3.7 解释器编写以下代码。
import time
start = time.time()
from demorphy import Analyzer
end = time.time()
print(end-start)
输出为
0.46335792541503906
当 运行 使用 Pycharm 调试器时,输出是
/home/user/virtualenvs/demorphy_test/bin/python3 /home/user/programs/pycharm-community-2019.2.1/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 57954 --file /home/user/demorphy_test/test.py
713.0500545501709
当 运行 使用 Visual Studio 代码调试器时,输出是
/home/user/virtualenvs/ptdev/bin/python /home/user/.vscode/extensions/ms-python.python-2019.10.41019/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 42604 /home/user/demorphy_test/test.py
693.3676333427429
Terminated
当 运行 使用 Eclipse Pydev 调试器时,输出是
pydev debugger: starting (pid: 26462)
706.7083044052124
为什么使用调试器 运行 时导入语句需要这么长时间? 我怎样才能让它 运行 更快?
需要安装demorphy依赖的dawg库https://github.com/pytries/DAWG/issues/31
由于 Python 调试器的工作方式和导入方式,它很慢。在 Python 中导入实际上是在执行模块中的代码。在调试器下执行代码本来就比较慢,因为执行的每一步都必须通过调试器以查看是否运行正常。命中断点。
加快调试速度的唯一方法是提高调试器的速度(VS Code 的 Python 扩展正在考虑引入一些调试器速度改进,但尚无时间表最初它们只会用于 Python 3.7).