《CPython Internals》阅读笔记:p353-p355

《CPython Internals》学习第 18天,p353-p355 总结,总计 3 页。

一、技术总结

1.benchmark(基准测试)

Python中常用的 benchmark 有 timeit, pyperformance。

(1)timeit

$ ./python -m timeit -c "x=1; x+=1; x**x"

1000000 loops, best of 5: 258 nsec per loop

我觉得这是一个很糟糕的示例,没有看出这个示例有什么意义。对于timeit 模块,我更希望放在整个项目中去看,看看它在实际项目中的应用。很遗憾,截止到目前,在我所看过的书中,关于 timeit 的使用都是测试一些代码片段。

(2)关于timeit的一点说明

作者在第356也说"You might notice a minor (1-5%) improvement in performance."------我觉得作者在这里的叙述有点本末倒置,timeit顶多算是验证结果的一种手段,其实应该把重点放在"为什么性能提升了1-5%"。

2.profiler

Python 中常用的 profiler 有 cProfiler 或者 dtrace。

二、英语总结(生词:2)

1.detrimental

(1)detriment: de-("away") + terere("to rub(摩擦), wear(to become weaker)")

u. harm or damage. Detriment refects the sense of sth being gradually worn away(使...磨损),leading to harm or less。

(2)detrimental

adj. causing harm or damage.

When making changes to CPython, you need to verify that your changes do not have a significant detrimental impact on performance(《CPython Internals》第353页)。

2.median

(1)median

c. the value that is the middle one in a set of values arranged in order of size(中位数,中值)。示例:1.假设有一组数 1, 3, 3, 6, 7, 8, 9, 那么 median 是6。2.假设有一组数1, 2, 3, 4, 5, 6, 8, 9,那么 median 是(4+5)/2=4.5。

A benchmark will produce an average/median runtime of a fixed code snippet so that you can compare multiple versions of Python runtime(《CPython Internals》第353页。)

关于英语的注解同步更新汇总到 https://github.com/codists/English-In-CS-Books 仓库。

三、其它

今天没有什么想说的。

四、参考资料

1. 编程

(1) Anthony Shaw,《CPython Internals》:https://book.douban.com/subject/35405785/

2. 英语

(1) Etymology Dictionary:https://www.etymonline.com

(2) Cambridge Dictionary:https://dictionary.cambridge.org

欢迎搜索及关注:编程人(a_codists)

相关推荐
时早玖沐4 分钟前
KOOK「找不到语音频道」:同一个错误假设,我犯了三次
python·开源·ai编程
_冷眸_6 分钟前
Python 调用大模型 API:最小请求、Base URL 和 401/404 排查
开发语言·人工智能·python
Dumbness25 分钟前
UIA 读微信群消息没有 id,怎么判断哪条是新的:后缀对齐在翻历史和撤回时整屏重报
python·算法
甜到心里的蛋糕31 分钟前
从 QQ 机器人到 B 站 AI 运营:一套可复现的视频流水线踩坑实录
运维·人工智能·python·自动化·视频制作
张驰咨询公司33 分钟前
六西格玛Python DOE试验矩阵:3因子2水平生成与验算
python·六西格玛·实验设计·itertools·doe试验矩阵
像风一样自由20201 小时前
2.如何用FastAPI把一个Python算法封装成HTTP服务
python·算法·fastapi
青少儿编程课堂1 小时前
蓝桥杯·全国青少年信息素养大赛·电子学会Python/C++考级:字典树前缀树与单词检索统计
c++·python·算法·bfs·信息学竞赛
田里的水稻1 小时前
FA_CNN卷积神经网络十八---感知机到多层感知机PyTorch
人工智能·pytorch·python
終不似少年遊*2 小时前
【Skill】为中型研发团队制作的敏捷迭代AI副驾Skill
人工智能·python·华为云·agent·ai编程·skill
呆萌的代Ma2 小时前
python使用ThreadPoolExecutor自带队列将多线程变串行执行
python