Python之父:让 Python 速度快2倍

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"近日,在美国参加 PyCon 语言峰会的 Guido van Rossum 表示,必须让 Python 语言的速度水平提高2倍,借此与 C++ 等高性能编程语言正面对抗。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Core Python(CPython)的市场吸引力也证明了上述论断,其出色的运行速度已经催生出 Pyston 等多种实现方案。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"正是由于天然性能不足,才让 Python 语言更多在数据科学与机器学习领域得以施展——这类工作负载主要由 GPU 负责处理,因此抵消了大部分速度劣势。当然,Python 也确实成就了 NumPy 以及 TensorFlow 机器学习框架等多种特定领域库,建立起自己的数据科学与机器学习应用优势。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"van Rossum 的雄心"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"上周,2021Python 语言峰会 PyCon 正式召开。在峰会上,van Rossum 在 GitHub 上发布了一份文档,详尽介绍了自己提升 Python 速度表现的雄心壮志。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/ad\/ad8ec250b3b531c5dec8765952a15c52.jpeg","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在文档中,他披露了“Shannon Plan”项目,承诺 4 年把 Python 速度提升 5 倍。并且在 Python 3.11 版本,实现 Python 速度提高2倍的目标。据悉,Python 3.11 是计划于明年发布 pre-alpha 版本的 Python 三个分支之一。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"闲不住的大牛"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"30 年前,由于对已有的编程语言感到十分失望,van Rossum 决定开发一门新语言——一门既易于使用功能又强大的语言。于是,Python 诞生了。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"目前,Python 已经发展成世界上非常流行的编程语言,有无数开发者使用它处理大大小小的任务,特别是 Web 开发人员、数据科学家和系统管理员。并且,Python 也在一些世界知名的组织中扮演着关键角色,比如,Netflix 用 Python 向全球 1 亿多户家庭提供流媒体视频,Instagram 用 Python 实现图片分享,NASA 借助 Python 来探索太空。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"去年 11 月,van Rossum 决定离开“退休”状态重返工作,正式加盟微软。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"而在退休前,他曾在 Dropbox 公司工作,并写下了 400 万行 Python 代码。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"他坦言,“退休后,每天闲坐在家简直无聊透顶”。为此,他申请了微软职位,并顺利出任微软杰出工程师这一实权职务。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"对此,微软也表现出自己对优秀人才的重视,允许他“自由选择项目”,这也让 van Rossum“再次回到自己熟悉的战场”。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"van Rossum 写道,“感谢微软以这样的方式回馈 Python 项目”。"}]},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/87\/87d2b5238f3eeea86c77deac4dfb49c9.jpeg","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"微软助力 Python 项目"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"据悉,微软公司长期以来一直以多种方式为 Python 项目提供助力,包括发布免费的 Python 课程(微软 Azure 云 AI 服务教程的一部分)、通过 VS Code Python 扩展在 Windows 10 及以上版本支持 Python,并成为 Python 项目的正式赞助商。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"此外,微软自 2006 年起开始成为 Python 软件基金会(PSF)的赞助商,并在今年提供了 15 万美元资助。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"van Rossum 表示,微软还资助了一支小型 Python 团队“负责语言解释层面的性能改进工作”。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"目前,微软共有五位专为 CPython 开发做出贡献的核心成员,分别为 Brett Cannon、Steve Dower、Guido van Rossum、Eric Snow 以及 Barry Warsaw,他们也都是 Python 核心开发者社区中的资深人士。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"微软在今年 4 月发表声明,提到 Eric Snow 一直在通过子解释器研究 Python 语言中的多线程性能。自 Python 3.5 版本开始,Steve Dower 出任 build 管理员,同时也是 Windows 平台的 CPython 专家。Barry Warsaw 则身为 Python 指导委员会成员、Python 安全响应小组成员并为 Python 版本管理器做出了贡献。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"并且,随着近期软件供应链攻击受到整个技术社区的高度关注,微软还将重点放在保护主程序包 repo PyPI(即 Python Package Index)身上。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"微软公司 Python 与 AI 工具首席经理 Dan Taylor 提到,“作为 PSF 15 万美元财务赞助中的一部分,我们将把资金集中到程序包工作小组当中,帮助他们进一步改善 PyPI 与程序包生态系统。”"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"“面对近期持续涌现的安全漏洞,我们与 Python 社区已经意识到建立可依赖供应链的重要意义,我们也很高兴能为这项长期改进做出切实贡献。”"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"van Rossum 对一些问题的回应"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"目前,van Rossum 也指出他和其他微软同事将携手核心 Python 开发人员推进公开贡献,目前正专注于对 CPython 进行增量式变更。之所以暂时不进行重大变更,是为了避免开发者们再次经历由 Python 2.x 迁移至 Python 3 的痛苦经历。整个迁移过程持续达十年之久,也给 Python 的群众基础造成不小的影响。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"van Rossum 写道,“如果分叉 \/ 分支不能长期存在,就不会有激动人心的 pull 产出。”"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"他还强调,“我们将继续负责维护与支持工作……所有讨论细节都将公开发布在 GitHub repo 当中。”"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"有部分资深人士认为 Python 的解释器及其 C 语言应用程序二进制接口(ABI)与应用程序协议接口(API)阻碍了 Python 在浏览器环境下的创新空间,van Rossum 也就此做出了回应。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"“首先不能破坏稳定 ABI 的兼容性;其次不能破坏有限 API 的兼容性;第三不能破坏或拖慢极端用例。总之,代码的可维护性才是第一要务。”"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"但核心 Python 项目是不是真能在 3.11 版本中将速度顺利加倍?van Rossum 好像心里也没底,所以在说明中给自己留了点后路。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/2e\/2e4cb74342139f13bdaa7e9921fba70a.jpeg","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"他写道,“我们还没法确定 2 倍速度的目标能不能实现。但乐观一点、好奇一点总没有错。”"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"而且他还大开脑洞,提出了在 Python 3.11 版本之后进一步将速度提高 5 倍的思路,并强调“我们必须保持旺盛的创造力。”"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"他提到,此次围绕性能展开的 Python 变更,将主要服务于那些“运行 CPU 密集型纯 Python 代码”的开发者以及采用内置 Python 的网站客户。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"但对于大家使用 C 语言编写的代码(例如 NumPy 与 TensorFlow)、I\/O 绑定代码、多线程代码以及算法代码,此次升级的效果就非常有限了。"}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章