# Python（编程语言）

**Python**是一种解释型、交互式、面向对象的编程语言，融合了模块、异常、动态类型、极高层级动态数据类型和类，除面向对象编程外还支持过程式和函数式风格。<sup>[1](https://docs.python.org/3/faq/general.html)</sup> 该语言得名于英国喜剧系列《蒙提·派森的飞行马戏团》（*Monty Python's Flying Circus*），而非蟒蛇。<sup>[2](https://www.cwi.nl/en/news/25-years-of-python-at-cwi/)</sup>

| 关键事实 | 详情 |
|---|---|
| 首次发布 | 0.9.0版，1991年2月20日，发布于阿姆斯特丹的CWI<sup>[2](https://www.cwi.nl/en/news/25-years-of-python-at-cwi/)</sup> |
| 设计渊源 | 借鉴ABC语言（用缩进表示语句分组、字符串和数字不可变、无需类型声明、内置字典和列表），并通过受Modula-2启发的模块获得可扩展性<sup>[3](https://computerhistory.org/blog/2018-chm-fellow-guido-van-rossum-python-creator-benevolent-dictator-for-life/)</sup> |
| 执行模型 | 解释型；源代码编译为字节码，由CPython虚拟机运行<sup>[1](https://docs.python.org/3/faq/general.html)</sup> |
| 并发 | 默认构建强制启用全局解释器锁（GIL）；自Python 3.13起，可选的自由线程构建可禁用GIL（PEP 703）<sup>[4](https://docs.python.org/3.15/c-api/threads.html)</sup><sup> • </sup><sup>[5](https://docs.python.org/3/howto/free-threading-python.html)</sup> |
| 当前版本 | Python 3.15.0，2026年10月9日发布，包含来自1,012名贡献者的5,643次提交<sup>[6](https://www.python.org/downloads/release/python-3150/)</sup> |
| 治理 | 依据PEP 13设立的五人指导委员会，经2018年12月社区投票后采纳<sup>[7](https://peps.python.org/pep-0013/)</sup> |
| 许可 | 一整套开源许可证；自2.0.1版以来新增的所有内容均受PSF许可证覆盖<sup>[8](https://www.python.org/psf/summary/)</sup> |
| 生态系统 | 大多数开发者从PyPI安装软件包（2024年开发者调查中占83%）<sup>[9](https://lp.jetbrains.com/python-developers-survey-2024/)</sup> |

## 在CWI的起源

范罗苏姆于1982年底加入CWI，在由兰伯特·梅尔滕斯和史蒂文·彭伯顿领导的ABC小组中担任程序员。ABC的设计目标是让没有编程经验的人（如科学家）能够快速编写程序，但该项目未能获得用户基础，最终被终止。<sup>[3](https://computerhistory.org/blog/2018-chm-fellow-guido-van-rossum-python-creator-benevolent-dictator-for-life/)</sup><sup> • </sup><sup>[10](https://gvanrossum.github.io/python-history/personal-history-part-1-cwi.html)</sup> 范罗苏姆随后转入Amoeba小组，Amoeba是一个基于微内核的分布式操作系统，由CWI和阿姆斯特丹自由大学在安德鲁·塔能鲍姆的领导下联合开发。<sup>[10](https://gvanrossum.github.io/python-history/personal-history-part-1-cwi.html)</sup>

**动机。** 用C语言编写Amoeba的系统管理工具耗时过长，而[Bourne shell](https://www.edgepedia.org/zh/bourne-shell)无法表达Amoeba的细粒度原语操作。范罗苏姆想要一种能——用他的话说——“弥合C与shell之间鸿沟”的语言，而现有语言都不适合他：Perl 3与Unix绑定过紧，其语法也不合他的口味。他于1989年12月下旬开始开发Python，1990年头几个月就有了可运行的版本，而他写下的第一段实现代码是一个名为“pgen”的LL(1)解析器生成器，至今仍是Python源码分发的一部分。<sup>[10](https://gvanrossum.github.io/python-history/personal-history-part-1-cwi.html)</sup>

Python从ABC继承了用缩进表示语句分组、字符串和数字不可变、无需类型声明以及内置字典和列表等特性。它通过模块实现了高度可扩展性，从而改进了ABC，这一想法受[尼克劳斯·维尔特](https://www.edgepedia.org/zh/niklaus-wirth)设计的Modula-2启发。与ABC一样，Python是解释型和交互式的，具有适合新手、教学和快速原型开发的动态运行时类型系统。<sup>[3](https://computerhistory.org/blog/2018-chm-fellow-guido-van-rossum-python-creator-benevolent-dictator-for-life/)</sup> 从一开始，它就以修改版MIT风格许可证作为自由软件提供，比“开源”一词被创造出来还早了好几年。<sup>[3](https://computerhistory.org/blog/2018-chm-fellow-guido-van-rossum-python-creator-benevolent-dictator-for-life/)</sup> 早期版权声明（1991—1995年）由阿姆斯特丹的数学中心基金会持有，修改版本后来由国家研究创新公司（CNRI）提供。<sup>[11](https://www.python.org/doc/copyright/)</sup>

## 语言特性

Python将其文档所称的非凡能力与非常清晰的语法结合在一起。程序通常比等效的C、C++或Java程序短得多，原因有三：高层数据类型可在单条语句中表达复杂操作；语句分组通过缩进而非括号完成；无需变量或参数声明。<sup>[12](https://docs.python.org/3.15/tutorial/appetite.html)</sup> 解释器可以交互式使用，支持实验和自底向上的程序开发，且无需编译或链接步骤。<sup>[12](https://docs.python.org/3.15/tutorial/appetite.html)</sup>

**可扩展性。** 解释器可以轻松地用C或C++实现的新函数和数据类型来扩展，也可以用可从C调用的其他语言扩展，而Python本身可作为可定制应用程序的扩展语言。<sup>[13](https://docs.python.org/3.10/tutorial/)</sup> 这一扩展机制构成了数值计算和机器学习库的基础，如NumPy、Pandas、TensorFlow、Scikit-learn、SciPy和[Matplotlib](https://www.edgepedia.org/zh/matplotlib)，正是这些库使Python成为数据科学和机器学习开发的首选语言。<sup>[14](https://arxiv.org/abs/2302.03307)</sup>

## GIL与自由线程

在默认的CPython构建中，线程在访问Python对象之前必须持有全局解释器锁（GIL）。没有该锁，即使简单操作也可能破坏状态；例如，两个线程同时递增同一对象的引用计数，可能导致它只被递增一次而非两次。同一时刻只有一个线程执行Python字节码，解释器在字节码指令之间切换线程，因此在纯Python代码中仍需要锁来保证线程安全。GIL在执行阻塞式I/O操作期间会释放。<sup>[4](https://docs.python.org/3.15/c-api/threads.html)</sup> 对于CPU密集型工作，这限制了线程的加速效果，需要多核计算的程序一直被建议改用`multiprocessing`或`concurrent.futures.ProcessPoolExecutor`。<sup>[15](https://docs.python.org/3.15/library/threading.html)</sup>

**自由线程构建。** 从3.13版开始，CPython支持一种名为自由线程的可选构建，其中GIL被禁用，允许线程在可用的CPU核心上并行运行。为线程设计的程序在多核硬件上运行更快，但并非所有软件都能自动受益，某些第三方扩展模块在加载时会重新启用GIL。<sup>[5](https://docs.python.org/3/howto/free-threading-python.html)</sup> 该设计遵循PEP 703，用细粒度机制取代单一锁：`dict`、`list`和`set`等内置类型使用内部锁，偏向引用计数和延迟引用计数减少争用，某些对象被设为永生对象，即永不释放、其引用计数永不修改。<sup>[5](https://docs.python.org/3/howto/free-threading-python.html)</sup>

自由线程构建也有代价。在pyperformance基准测试套件上，单线程开销从macOS aarch64上约1%到x86-64 Linux上8%不等，该构建通常使用更多内存，且某些操作不安全，例如访问另一线程中正在执行的帧的`frame.f_locals`可能导致解释器崩溃。<sup>[5](https://docs.python.org/3/howto/free-threading-python.html)</sup> 自由线程构建仍可在运行时通过`PYTHON_GIL`环境变量或`-X gil`选项启用GIL，当导入未标记为自由线程安全的扩展模块时，GIL会自动重新启用。<sup>[5](https://docs.python.org/3/howto/free-threading-python.html)</sup>

## 性能

解释型、动态类型的执行有可测量的代价。2022年USENIX ATC的一项研究以C++为基线对Java、Go、JavaScript和Python进行了插桩测试，发现CPython应用程序平均比对应的C++程序慢29.50倍，且扩展性差。<sup>[16](https://www.usenix.org/system/files/atc22-lion.pdf)</sup> 在实践中，许多性能关键的Python工作运行在优化的C扩展库中，而Numba等编译器可以在合适的基准测试上使数值Python接近C++和Go的速度。<sup>[17](https://arxiv.org/abs/2001.02491)</sup>

CPython本身一直在增加编译功能。Python 3.15还新增了显式惰性导入以加快启动速度（PEP 810）、以UTF-8为默认编码（PEP 686），以及包括`frozendict`和`sentinel`在内的新内置类型。<sup>[6](https://www.python.org/downloads/release/python-3150/)</sup>

## 治理、社区与生态系统

Python的开发通过Python增强提案（PEP）协调，非营利组织Python软件基金会（PSF）拥有该语言的知识产权，包括编程语言领域内的“Python”商标。<sup>[3](https://computerhistory.org/blog/2018-chm-fellow-guido-van-rossum-python-creator-benevolent-dictator-for-life/)</sup><sup> • </sup><sup>[8](https://www.python.org/psf/summary/)</sup> 20世纪90年代末，社区成员开玩笑地授予范罗苏姆“终身仁慈独裁者”的称号；经过一场治理辩论，2018年12月的核心开发者投票采纳了指导委员会模式，由五人委员会拥有广泛但刻意节制的权力，包括接受或拒绝PEP。<sup>[3](https://computerhistory.org/blog/2018-chm-fellow-guido-van-rossum-python-creator-benevolent-dictator-for-life/)</sup><sup> • </sup><sup>[7](https://peps.python.org/pep-0013/)</sup>

由PSF和[JetBrains](https://www.edgepedia.org/zh/jetbrains)开展的年度Python开发者调查在2024年10月和11月收集了来自近200个国家和地区的30,000多份回复。受访者最常用Python进行Web开发（46%）和数据科学，即数据分析或机器学习（45%），83%的人从PyPI安装软件包。<sup>[9](https://lp.jetbrains.com/python-developers-survey-2024/)</sup> 采用人群偏向经验较少的程序员：半数受访用户经验不足两年，72%的人表示将Python用于工作。<sup>[18](https://www.techradar.com/pro/python-isnt-dead-despite-funding-cuts-programming-language-powers-on)</sup> Python在2022年PYPL和TIOBE两个流行度指数上均排名第一。<sup>[14](https://arxiv.org/abs/2302.03307)</sup>

## 发布与支持模式

Python遵循每年发布一个大版本、支持窗口较长的节奏。Python 3.13于2024年10月7日首次发布，安全支持持续到2029年10月；Python 3.14于2025年10月7日跟进，支持到2030年10月；Python 3.15于2026年10月9日发布，支持到2031年10月。<sup>[19](https://devguide.python.org/versions/?source=post_page-----4134150b6b0d--------------------------------)</sup> 升级滞后于发布：在2024年调查中，21%的受访者表示使用3.11版，35%使用3.12版，83%的企业运行的是已发布至少一年的版本。<sup>[20](https://www.itpro.com/software/python-programming-language-developers-older-versions-upgrade)</sup>

## References

1. [General Python FAQ, Python 3.15.0 documentation](https://docs.python.org/3/faq/general.html)
2. [25 Years of Python at CWI, Centrum Wiskunde & Informatica](https://www.cwi.nl/en/news/25-years-of-python-at-cwi/)
3. [2018 Museum Fellow Guido van Rossum, Computer History Museum](https://computerhistory.org/blog/2018-chm-fellow-guido-van-rossum-python-creator-benevolent-dictator-for-life/)
4. [Thread states and the global interpreter lock, Python 3.15.0 documentation](https://docs.python.org/3.15/c-api/threads.html)
5. [Python support for free threading, Python 3.15.0 documentation](https://docs.python.org/3/howto/free-threading-python.html)
6. [Python Release Python 3.15.0, Python.org](https://www.python.org/downloads/release/python-3150/)
7. [PEP 13 – Python Language Governance, peps.python.org](https://peps.python.org/pep-0013/)
8. [Executive Summary: The Python Software Foundation, Python.org](https://www.python.org/psf/summary/)
9. [Python Developers Survey 2024 Results, JetBrains and PSF](https://lp.jetbrains.com/python-developers-survey-2024/)
10. [Personal History - part 1, CWI, The History of Python (Guido van Rossum)](https://gvanrossum.github.io/python-history/personal-history-part-1-cwi.html)
11. [Python Copyright, Python.org](https://www.python.org/doc/copyright/)
12. [Whetting Your Appetite, Python 3.15 tutorial](https://docs.python.org/3.15/tutorial/appetite.html)
13. [The Python Tutorial, Python 3.10 documentation](https://docs.python.org/3.10/tutorial/)
14. [Castro, Bruneau, Sottet, Torregrossa (2023). Landscape of High-performance Python to Develop Data Science and Machine Learning Applications. arXiv.](https://arxiv.org/abs/2302.03307)
15. [threading — Thread-based parallelism, Python 3.15.0 documentation](https://docs.python.org/3.15/library/threading.html)
16. [Investigating Managed Language Runtime Performance, USENIX ATC 2022](https://www.usenix.org/system/files/atc22-lion.pdf)
17. [Comparing Python, Go, and C++ on the N-Queens Problem, arXiv](https://arxiv.org/abs/2001.02491)
18. [Python isn't dead - despite funding cuts, programming language powers on, TechRadar](https://www.techradar.com/pro/python-isnt-dead-despite-funding-cuts-programming-language-powers-on)
19. [Status of Python versions, Python Developer's Guide](https://devguide.python.org/versions/?source=post_page-----4134150b6b0d--------------------------------)
20. [Using an older version of Python? You're leaving 'money and performance on the table', ITPro](https://www.itpro.com/software/python-programming-language-developers-older-versions-upgrade)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Programming languages › Individual programming languages › C-family and imperative languages

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/python-programming-language

English original: https://www.edgepedia.org/python-programming-language
