python - Python 脚本第一次执行需要几秒钟
问题描述
我有一台带有 High Sierra 版本 10.13.6 的新 Mac。默认安装的python有版本:
➜ ~ python --version
Python 2.7.10
我安装了python 3:
➜ ~ brew install python
所以我得到:
➜ ~ python3 --version
Python 3.7.0
使用这两个版本的python,当我运行一个非常简单的脚本时:
print("this is the text")
第一次执行很慢:
➜ ~ time python3 test.py
this is the text
python3 test.py 0.02s user 0.02s system 1% cpu 2.945 total
随后的执行速度要快得多:
➜ ~ time python3 test.py
this is the text
python3 test.py 0.03s user 0.02s system 70% cpu 0.071 total
每当我更改脚本中的某些内容并重新运行它时,第一次执行非常慢。这发生在两个版本的 python 中。我在 ubuntu 上尝试了相同的步骤,但没有证据表明这个问题。
我错过了什么?我怎样才能使第一次执行在合理的时间内运行?
解决方案
推荐阅读
- unity3d - tilemap collider 2d 生成的collider 略大
- python - 将字典列表导入python以转换为csv文件
- xml - QAF - Webservices 测试不从 XML 获取 Xpath 值
- java - Java Hashmap if 语句检查不起作用
- textbox - Visio 另存为 JPEG 创建更大的图像
- java - 如何使用 Thymeleaf 在 Spring 中发布其他实体的 ArrayList
- html - Html 菜单向右移动 - 向左移动
- javascript - 尝试将模板中的几何加载器从 TDS 更改为 gltf
- java - 如何使用 AJAX 从 restcontroller 打印数据?
- c# - 为什么我的 Azure API 在本地环境中运行时返回 500 内部服务器错误?