Python programs pay for their imports at every process start, a cost that is invisible in steady-state benchmarks but dominant for command-line tools, test workers, and serverless cold starts. Python 3.15 adds explicit lazy imports (PEP 810) on largely anecdotal evidence. We measure the import cost of the 500 most-downloaded PyPI packages, every quarterly release since mid-2021, under six CPython versions (3.9-3.14) on two platforms (Apple M5/macOS and Intel Xeon/Linux), 66,816 cells in all, with targeted experiments that isolate individual effects. Values are for macOS (Linux in parentheses). Import cost is heavily skewed (median 12.3 ms, 99th percentile 400 ms). Among packages that import in more than 2 ms, namespace distributions excluded, the median package spends 68% of its import time in the standard library (68% on Linux with the interpreter on local storage, 79% on network storage). Precompiling bytecode removes almost all of the cold-start penalty on Linux and 92% of it for the median package on macOS, but only a third of the summed macOS penalty: packages with native libraries pay a security assessment of each library that the system has not seen before, again in every fresh environment. A package's own import code grows by a median 4.0% (5.0%) per year; installing each release with the dependencies of its time changes its trend by a median of only 0.15 (0.35) percentage points (CPython 3.9). CPython 3.14 runs package code faster than 3.9 but imports more and slower standard-library modules, a net 1.16x (1.07x) slowdown. Submodules that dependents import beyond the top level add nothing for the median package and at most 11.7 (49.5) ms for nine packages in ten. On CPython 3.15, global lazy mode cuts the imports that dependents perform to 0.41x (0.39x) of their cost, and 38 of 461 packages fail under it, many only on first use of a name. Harness, code, and dataset are public.


翻译:暂无翻译

0
下载
关闭预览

相关内容

【干货书】数值Python计算,Numerical Python,709页pdf
专知会员服务
116+阅读 · 2021年5月30日
【干货书】面向计算科学和工程的Python导论,167页pdf
专知会员服务
42+阅读 · 2021年4月7日
专知会员服务
53+阅读 · 2020年9月2日
Python计算导论,560页pdf,Introduction to Computing Using Python
专知会员服务
77+阅读 · 2020年5月5日
【干货书】流畅Python,766页pdf,中英文版
专知会员服务
229+阅读 · 2020年3月22日
【新书】Python中的经典计算机科学问题,224页pdf
专知会员服务
149+阅读 · 2019年12月28日
【新书】Python编程基础,669页pdf
专知会员服务
199+阅读 · 2019年10月10日
爆红GitHub!有人打算用这个项目100天拿下Python
程序猿
16+阅读 · 2019年5月15日
利用动态深度学习预测金融时间序列基于Python
量化投资与机器学习
18+阅读 · 2018年10月30日
荐书丨Python数据分析从入门到精通
程序人生
19+阅读 · 2018年3月31日
福利 | 当Python遇上大数据与机器学习,入门so easy!
用Python制作3D动画
Python程序员
30+阅读 · 2018年1月17日
Python 书单:从入门到……
Linux中国
41+阅读 · 2017年8月6日
国家自然科学基金
2+阅读 · 2017年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
VIP会员
最新内容
《美空军2026条令文件:对海压制作战》
专知会员服务
22+阅读 · 11月9日
人工智能与战争的未来
专知会员服务
9+阅读 · 11月8日
《Agent Mosaic:识别智能体LLM系统中的机密泄露》
专知会员服务
10+阅读 · 11月8日
人工智能在军事教育中的应用:若干视角与经验
专知会员服务
11+阅读 · 11月6日
“星链”减速与不断适应的乌克兰
专知会员服务
9+阅读 · 11月6日
美国中期选举之后:帕兰提尔面临不确定性?
专知会员服务
6+阅读 · 11月6日
相关VIP内容
【干货书】数值Python计算,Numerical Python,709页pdf
专知会员服务
116+阅读 · 2021年5月30日
【干货书】面向计算科学和工程的Python导论,167页pdf
专知会员服务
42+阅读 · 2021年4月7日
专知会员服务
53+阅读 · 2020年9月2日
Python计算导论,560页pdf,Introduction to Computing Using Python
专知会员服务
77+阅读 · 2020年5月5日
【干货书】流畅Python,766页pdf,中英文版
专知会员服务
229+阅读 · 2020年3月22日
【新书】Python中的经典计算机科学问题,224页pdf
专知会员服务
149+阅读 · 2019年12月28日
【新书】Python编程基础,669页pdf
专知会员服务
199+阅读 · 2019年10月10日
相关资讯
爆红GitHub!有人打算用这个项目100天拿下Python
程序猿
16+阅读 · 2019年5月15日
利用动态深度学习预测金融时间序列基于Python
量化投资与机器学习
18+阅读 · 2018年10月30日
荐书丨Python数据分析从入门到精通
程序人生
19+阅读 · 2018年3月31日
福利 | 当Python遇上大数据与机器学习,入门so easy!
用Python制作3D动画
Python程序员
30+阅读 · 2018年1月17日
Python 书单:从入门到……
Linux中国
41+阅读 · 2017年8月6日
相关基金
国家自然科学基金
2+阅读 · 2017年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员