Python (programming language): Difference between revisions
imported>Erictleung Undid revision 1297037589 by Zaamin Khan (talk) Context for GIL is important to understand PEP feature |
imported>Hooman Mallahzadeh Memory management in Infobox. |
||
| Line 1: | Line 1: | ||
{{Short description|General-purpose programming language}} | {{Multiple issues|{{Update|reason=Information related to stable Python version 3.14.0 is not present|date=October 2025}}{{Cleanup list|date=October 2025}}}}{{Short description|General-purpose programming language}} | ||
{{Use dmy dates|date=November 2021}} | {{Use dmy dates|date=November 2021}} | ||
{{Use American English|date=December 2024}} | {{Use American English|date=December 2024}} | ||
| Line 5: | Line 5: | ||
| logo = Python-logo-notext.svg | | logo = Python-logo-notext.svg | ||
| logo size = 150px | | logo size = 150px | ||
| paradigm = [[Multi-paradigm]]: [[object-oriented]],<ref>{{Cite web|title=General Python FAQ – Python 3 documentation|url=https://docs.python.org/3/faq/general.html#what-is-python|access-date=2024 | | paradigm = [[Multi-paradigm]]: [[Object-oriented programming|object-oriented]],<ref>{{Cite web |title=General Python FAQ – Python 3 documentation |url=https://docs.python.org/3/faq/general.html#what-is-python |access-date=7 July 2024 |website=docs.python.org}}</ref> [[Procedural programming|procedural]] ([[Imperative programming|imperative]]), [[Functional programming|functional]], [[Structured programming|structured]], [[Reflective programming|reflective]] | ||
| released = {{start date and age|1991|02|20|df=y}}<ref name="alt-sources-history">{{cite web |url=https://www.tuhs.org/Usenet/alt.sources/1991-February/001749.html | | | released = {{start date and age|1991|02|20|df=y}}<ref name="alt-sources-history">{{cite web |title=Python 0.9.1 part 01/21 |url=https://www.tuhs.org/Usenet/alt.sources/1991-February/001749.html |url-status=live |archive-url=https://web.archive.org/web/20210811171015/https://www.tuhs.org/Usenet/alt.sources/1991-February/001749.html |archive-date=11 August 2021 |access-date=11 August 2021 |publisher=alt.sources archives}}</ref> | ||
| designer = [[Guido van Rossum]] | | designer = [[Guido van Rossum]] | ||
| developer = [[Python Software Foundation]] | | developer = [[Python Software Foundation]] | ||
| latest release version = {{wikidata|property|P548=Q2804309|P348}} | | latest release version = {{wikidata|property|edit|reference|P548=Q2804309|P348}} | ||
| latest release date = {{start date and age|{{wikidata|qualifier|single|P548=Q2804309|P348|P577}}}} | | latest release date = {{start date and age|{{wikidata|qualifier|single|P548=Q2804309|P348|P577}}}} | ||
| latest preview version = {{wikidata|property|edit|reference|P548=Q51930650|P348}} | | latest preview version = <!-- 3.15.0a1 on 15 October 2025 {{wikidata|property|edit|reference|P548=Q51930650|P348}} doesn't work, nor what AI suggested as fix: {{#invoke:Wikidata | claim | P348 | qualifier = P548:Q51930650 | rank = best }} --> | ||
| latest preview date = {{start date and age|{{wikidata|qualifier| | | latest preview date = {{start date and age|2025|08|18|df=y}} <!-- {{start date and age|{{wikidata|qualifier|Q28865 |P548=Q51930650|P348|P577}}}} nor | ||
| typing = [[Duck typing| | {{#invoke:Wikidata | qualifier | P348 | P577 | qualifier = P548:Q51930650 | rank = best | formatting = date }} | ||
| implementations = [[CPython]], [[PyPy]], [[ | --> | ||
| operating system = {{ | | typing = [[Duck typing|Duck]], [[Dynamic typing|dynamic]], [[Strong and weak typing|strong]];<ref>{{Cite web |title=Why is Python a dynamic language and also a strongly typed language |url=https://wiki.python.org/moin/Why%20is%20Python%20a%20dynamic%20language%20and%20also%20a%20strongly%20typed%20language |url-status=live |archive-url=https://web.archive.org/web/20210314173706/https://wiki.python.org/moin/Why%20is%20Python%20a%20dynamic%20language%20and%20also%20a%20strongly%20typed%20language |archive-date=14 March 2021 |access-date=27 January 2021 |website=Python Wiki}}</ref> [[Optional typing|optional type annotations]]{{efn|since 3.5, but those hints are ignored, except with unofficial tools<ref name="type_hint-PEP">{{cite web |last1=van Rossum |first1=Guido |last2=Levkivskyi |first2=Ivan |title=PEP 483 – The Theory of Type Hints |url=https://www.python.org/dev/peps/pep-0483/ |url-status=live |archive-url=https://web.archive.org/web/20200614153558/https://www.python.org/dev/peps/pep-0483/ |archive-date=14 June 2020 |access-date=14 June 2018 |website=Python Enhancement Proposals (PEPs)}}</ref>}} | ||
*'''Tier 1''': 64-bit [[Linux]], [[macOS]]; 64- and 32-bit [[Windows]] 10+<ref>{{Cite web |title=PEP 11 – CPython platform support | | memory management = [[Garbage collection (computer science)|Garbage-collected]] | ||
| implementations = [[CPython]], [[PyPy]], [[MicroPython]], [[CircuitPython]], [[IronPython]], [[Jython]], [[Stackless Python]] | |||
| operating system = [[Cross-platform]] including 32-bit [[Windows 10]]<!-- with latest Python 3.14, Win8.1 still supported with older --> and e.g. for mobile; [[Android (operating system)|Android]] and [[iOS]] <small>(both 64-bit)</small><!-- downloadable official Python 3.14 Android binary executable available; still only tier 3 support. Strangely I find only Android, no iOS, official executable download despite it has "arm64-apple-ios" tier 3 support, so only downloadable as source code; and as unofficial iOS/iPadOS download?! -->{{efn| | |||
* '''Tier 1''': 64-bit [[Linux]], [[macOS]]; 64- and 32-bit [[Windows 8.1]] and later with older Python versions<!-- Windows 8.1 supported with 3.10 to 3.13 but only Windows 10+ with latest Python 3.14)+<ref>{{Cite web |last1=von Löwis |first1=Martin |last2=Cannon |first2=Brett |title=PEP 11 – CPython platform support |url=https://peps.python.org/pep-0011/ |access-date=22 April 2024 |website=Python Enhancement Proposals (PEPs) |language=en}}</ref><!-- Not "Windows for IoT and embedded systems"; NOT UNIX, it's not listed, nor any Unix-like, maybe implied Possibly Windows 8.1 is also supported on at least Python 3.9? Might also work on latest, seems too minor to mention, for any Python version. Windows 7 and 8 are prevented to work on Python 3.9, though it might not rule out 8.1, also some info like this might be a bit wrong: | |||
"Windows 8 and newer for Python 3.9 | "Windows 8 and newer for Python 3.9 | ||
| Line 22: | Line 25: | ||
macOS Snow Leopard (macOS 10.6, 2008) and newer" | macOS Snow Leopard (macOS 10.6, 2008) and newer" | ||
--> | --> | ||
*'''Tier 2''': E.g. 32-bit [[WebAssembly]] (WASI) <!-- (WASI SDK, Wasmtime) meaning wasm32-unknown-wasi; wasm32-unknown-emscripten is unsupported since 3.13. aarch64-pc-windows-msvc and powerpc64le-unknown-linux-gnu --> | * '''Tier 2''': E.g. 32-bit [[WebAssembly]] (WASI) <!-- (WASI SDK, Wasmtime) meaning wasm32-unknown-wasi; wasm32-unknown-emscripten is unsupported since 3.13. aarch64-pc-windows-msvc and powerpc64le-unknown-linux-gnu --> | ||
*'''Tier 3''': 64-bit [[Android (operating system)|Android]]<!-- too much trivia to mention "5.0+", even if true, it seemingly is, and corresponding API levels, but thouse are ancient, possibly even only way more recent is officially supported? -->,<ref>{{Cite web |title=PEP 738 – Adding Android as a supported platform {{!}} peps.python.org |url=https://peps.python.org/pep-0738/ |access-date=2024 | * '''Tier 3''': 64-bit [[Android (operating system)|Android]]<!-- too much trivia to mention "5.0+", even if true, it seemingly is, and corresponding API levels, but thouse are ancient, possibly even only way more recent is officially supported? -->,<ref>{{Cite web |title=PEP 738 – Adding Android as a supported platform {{!}} peps.python.org |url=https://peps.python.org/pep-0738/ |access-date=19 May 2024 |website=Python Enhancement Proposals (PEPs) |language=en}}</ref> [[iOS]], [[FreeBSD]], and (32-bit) [[Raspberry Pi OS]]<br />Unofficial (or has been known to work): Other [[Unix-like]]/[[BSD]] variants) and a few other platforms<!-- Used to support many more, only few support latest 3.9+ --><ref name="DownloadOther">{{Cite web |title=Download Python for Other Platforms |url=https://www.python.org/download/other/ |url-status=live |archive-url=https://web.archive.org/web/20201127015815/https://www.python.org/download/other/ |archive-date=27 November 2020 |access-date=18 August 2023 |website=Python.org |language=en}}</ref><ref>{{Cite web |title=test – Regression tests package for Python |url=https://docs.python.org/3.7/library/test.html?highlight=android#test.support.is_android |url-status=live |archive-url=https://web.archive.org/web/20220517151240/https://docs.python.org/3.7/library/test.html?highlight=android#test.support.is_android |archive-date=17 May 2022 |access-date=17 May 2022 |website=Python 3.7.17 documentation}}</ref><ref>{{Cite web |title=platform – Access to underlying platform's identifying data |url=https://docs.python.org/3.10/library/platform.html?highlight=android |url-status=live |archive-url=https://web.archive.org/web/20220517150826/https://docs.python.org/3/library/platform.html?highlight=android |archive-date=17 May 2022 |access-date=17 May 2022 |website=Python 3.10.4 documentation}}</ref>}} | ||
<!-- | <!-- | ||
https://mail.python.org/archives/list/python-committers@python.org/thread/K757345KX6W5ZLTWYBUXOXQTJJTL7GW5/ | https://mail.python.org/archives/list/python-committers@python.org/thread/K757345KX6W5ZLTWYBUXOXQTJJTL7GW5/ | ||
* Alpine / musl is not supported, because our test suite is failing due to bugs and missing features in musl libc. | * Alpine / musl is not supported, because our test suite is failing due to bugs and missing features in musl libc. | ||
* NetBSD and OpenBSD are in a similar state as Alpine: no stable buildbot and AFAIK tests are failing | * NetBSD and OpenBSD are in a similar state as Alpine: no stable buildbot and AFAIK tests are failing | ||
| Line 39: | Line 41: | ||
.. | .. | ||
E.g. Android support was even funded by the PSF recently. [outdated] | E.g. Android support was even funded by the PSF recently.[outdated] | ||
Also note that the stdlib does in fact support other Python implementations reusing (parts of) it, e.g. Jython, PyPy and IronPython. Again, without core devs backing these. | Also, note that the stdlib does in fact support other Python implementations reusing (parts of) it, e.g. Jython, PyPy and IronPython. Again, without core devs backing these. | ||
--> | -->| license = [[Python Software Foundation License]] | ||
| license = [[Python Software Foundation License]] | | file ext = .py, .pyw, .pyz,<!-- Too much trivia?: (since 3.5), since 3.8 latest supported and Python 3.5.10 Sept. 5, 2020--><ref>{{cite web |last1=Holth |first1=Daniel |last2=Moore |first2=Paul |date=30 March 2014 |title=PEP 0441 – Improving Python ZIP Application Support |url=https://www.python.org/dev/peps/pep-0441/ |url-status=live |archive-url=https://web.archive.org/web/20181226141117/https://www.python.org/dev/peps/pep-0441/%20 |archive-date=26 December 2018 |access-date=12 November 2015 |website=Python Enhancement Proposals (PEPs)}}</ref><br /> | ||
| file ext = .py, .pyw, .pyz,<!-- Too much trivia?: (since 3.5), since 3.8 latest supported and Python 3.5.10 Sept. 5, 2020--><ref>{{cite web | | |||
.pyi, .pyc, .pyd<!-- too much trivia: .pyo (before 3.5)<ref>File extension .pyo was removed in Python 3.5. See [https://www.python.org/dev/peps/pep-0488/ PEP 0488] {{Webarchive|url=https://web.archive.org/web/20200601133202/https://www.python.org/dev/peps/pep-0488/ |date=1 June 2020}}</ref> --> | .pyi, .pyc, .pyd<!-- too much trivia: .pyo (before 3.5)<ref>File extension .pyo was removed in Python 3.5. See [https://www.python.org/dev/peps/pep-0488/ PEP 0488] {{Webarchive|url=https://web.archive.org/web/20200601133202/https://www.python.org/dev/peps/pep-0488/ |date=1 June 2020}}</ref> --> | ||
| website = {{URL|https://www.python.org/|python.org}} | | website = {{URL|https://www.python.org/|python.org}} | ||
| dialects = [[Cython]], [[RPython]], [[ | | dialects = [[Cython]], [[RPython]], [[Starlark]]<ref>{{cite web |title=Starlark Language |url=https://docs.bazel.build/versions/master/skylark/language.html |url-status=live |archive-url=https://web.archive.org/web/20200615140534/https://docs.bazel.build/versions/master/skylark/language.html |archive-date=15 June 2020 |access-date=25 May 2019 |website=bazel.build}}</ref> | ||
| influenced by = [[ABC (programming language)|ABC]],<ref name="faq-created"/> [[Ada (programming language)|Ada]],<ref>{{cite web |url=https://archive.adaic.com/standards/83lrm/html/lrm-11-03.html#11.3 | | | influenced by = [[ABC (programming language)|ABC]],<ref name="faq-created" /> [[Ada (programming language)|Ada]],<ref>{{cite web |title=Ada 83 Reference Manual (raise statement) |url=https://archive.adaic.com/standards/83lrm/html/lrm-11-03.html#11.3 |url-status=live |archive-url=https://web.archive.org/web/20191022155758/http://archive.adaic.com/standards/83lrm/html/lrm-11-03.html#11.3 |archive-date=22 October 2019 |access-date=7 January 2020 |website=archive.adaic.com}}</ref>{{failed verification|date=August 2025|reason=The source does not talk about Python. The "raise" keyword it describes is very similar to the Python version, but this is original research (see WP:OR).}} {{nowrap|[[ALGOL 68]]}},<ref name="98-interview" /> [[APL (programming language)|APL]],<ref name="python.org">{{cite web |title=itertools – Functions creating iterators for efficient looping |url=https://docs.python.org/3.7/library/itertools.html |url-status=live |archive-url=https://web.archive.org/web/20200614153629/https://docs.python.org/3/library/itertools.html |archive-date=14 June 2020 |access-date=22 November 2016 |website=Python 3.7.17 documentation |quote=This module implements a number of iterator building blocks inspired by constructs from APL, Haskell, and SML.}}</ref> [[C (programming language)|C]],<ref name="AutoNT-1" /> [[C++]],<ref name="classmix" /> [[CLU (programming language)|CLU]],<ref name="effbot-call-by-object" /> [[Dylan (programming language)|Dylan]],<ref name="AutoNT-2" /> [[Haskell]],<ref name="AutoNT-3" /><ref name="python.org" /> [[Icon (programming language)|Icon]],<ref name="AutoNT-4" /> [[Lisp (programming language)|Lisp]],<ref name="AutoNT-6" /> {{nowrap|[[Modula-3]]}},{{r |98-interview}}<ref name="classmix" /> [[Perl]],<ref>{{cite web |title=re – Regular expression operations |url=https://docs.python.org/3.10/library/re.html |url-status=live |archive-url=https://web.archive.org/web/20180718132241/https://docs.python.org/3/library/re.html |archive-date=18 July 2018 |access-date=6 September 2022 |website=Python 3.10.6 documentation |quote=This module provides regular expression matching operations similar to those found in Perl.}}</ref> [[Standard ML]]<ref name="python.org" /> | ||
| | | influenced = [[Apache Groovy]], [[Boo (programming language)|Boo]], [[Cobra (programming language)|Cobra]], [[CoffeeScript]],<ref>{{Cite web |title=CoffeeScript |url=https://coffeescript.org/ |url-status=live |archive-url=https://web.archive.org/web/20200612100004/http://coffeescript.org/ |archive-date=12 June 2020 |access-date=3 July 2018 |website=coffeescript.org}}</ref> [[D (programming language)|D]], [[F Sharp (programming language)|F#]], [[GDScript]], [[Go (programming language)|Go]], [[JavaScript]],<ref>{{cite web |last=Rauschmayer |first=Axel |date=24 February 2013 |title=Perl and Python influences in JavaScript |url=https://www.2ality.com/2013/02/javascript-influences.html |url-status=live |archive-url=https://web.archive.org/web/20181226141121/http://2ality.com/2013/02/javascript-influences.html%0A |archive-date=26 December 2018 |access-date=15 May 2015 |website=2ality.com}}</ref><ref>{{cite web |last=Rauschmayer |first=Axel |title=Chapter 3: The Nature of JavaScript; Influences |url=https://speakingjs.com/es5/ch03.html |url-status=live |archive-url=https://web.archive.org/web/20181226141123/http://speakingjs.com/es5/ch03.html%0A |archive-date=26 December 2018 |access-date=15 May 2015 |website=Speaking JavaScript |publisher=O'Reilly}}</ref> [[Julia (programming language)|Julia]],<ref name="Julia">{{cite web |last1=Bezanson |first1=Jeff |last2=Karpinski |first2=Stefan |last3=Shah |first3=Viral B. |last4=Edelman |first4=Alan |date=February 2012 |title=Why We Created Julia |url=https://julialang.org/blog/2012/02/why-we-created-julia |url-status=live |archive-url=https://web.archive.org/web/20200502144010/https://julialang.org/blog/2012/02/why-we-created-julia/ |archive-date=2 May 2020 |access-date=5 June 2014 |website=Julia website |quote=We want something as usable for general programming as Python [...]}}</ref> [[Mojo (programming language)|Mojo]],<ref name="Mojo">{{Cite web |last=Krill |first=Paul |date=4 May 2023 |title=Mojo language marries Python and MLIR for AI development |url=https://www.infoworld.com/article/3695588/mojo-language-marries-python-and-mlir-for-ai-development.html |url-status=live |archive-url=https://web.archive.org/web/20230505064554/https://www.infoworld.com/article/3695588/mojo-language-marries-python-and-mlir-for-ai-development.html |archive-date=5 May 2023 |access-date=5 May 2023 |website=InfoWorld |language=en}}</ref> [[Nim (programming language)|Nim]], [[Ring (programming language)|Ring]],<ref name="The Ring programming language and other languages">{{cite web |author=Ring Team |date=4 December 2017 |title=Ring and other languages |url=https://ring-lang.sourceforge.net/doc1.6/introduction.html#ring-and-other-languages |url-status=dead |archive-url=https://web.archive.org/web/20181225175312/http://ring-lang.sourceforge.net/doc1.6/introduction.html#ring-and-other-languages |archive-date=25 December 2018 |access-date=4 December 2017 |work=ring-lang.net |publisher=[[ring-lang]]}}</ref> [[Ruby (programming language)|Ruby]],<ref name="bini" /> [[Swift (programming language)|Swift]],<ref name="lattner2014">{{Cite web |last=Lattner |first=Chris |date=3 June 2014 |title=Chris Lattner's Homepage |url=http://nondot.org/sabre/ |url-status=live |archive-url=https://web.archive.org/web/20181225175312/http://nondot.org/sabre/ |archive-date=25 December 2018 |access-date=3 June 2014 |publisher=Chris Lattner |quote=The Swift language is the product of tireless effort from a team of language experts, documentation gurus, compiler optimization ninjas, and an incredibly important internal dogfooding group who provided feedback to help refine and battle-test ideas. Of course, it also greatly benefited from the experiences hard-won by many other languages in the field, drawing ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list.}}</ref> [[V (programming language)|V]]<ref name="vpeople">{{Cite web |title=V documentation (Introduction) |url=https://github.com/vlang/v/blob/master/doc/docs.md#introduction |access-date=24 December 2024 |website=GitHub |language=en}}</ref> | ||
<!-- Do not put in as there's a pure Java implementation (Jython): | programming language = [[C (programming language)|C]] -->| wikibooks = Python Programming | |||
<!-- Do not put in as there's | |||
| wikibooks = Python Programming | |||
}} | }} | ||
{{Template:Python sidebar}} | |||
'''Python''' is a [[high-level programming language|high-level]], [[general-purpose programming language]]. Its design philosophy emphasizes [[code readability]] with the use of [[significant indentation]].<ref name="AutoNT-7"/> | '''Python''' is a [[high-level programming language|high-level]], [[general-purpose programming language]]. Its design philosophy emphasizes [[code readability]] with the use of [[significant indentation]].<ref name="AutoNT-7" /> Python is [[type system#DYNAMIC|dynamically type-checked]] and [[garbage collection (computer science)|garbage-collected]]. It supports multiple [[programming paradigm]]s, including [[structured programming|structured]] (particularly [[procedural programming|procedural]]), [[Object-oriented programming|object-oriented]] and [[functional programming]]. | ||
Python is [[type system#DYNAMIC|dynamically type-checked]] and [[garbage collection (computer science)|garbage-collected]]. It supports multiple [[programming paradigm]]s, including [[structured programming|structured]] (particularly [[procedural programming|procedural]]), [[object-oriented]] and [[functional programming]]. | |||
[[Guido van Rossum]] began working on Python in the late 1980s as a successor to the [[ABC (programming language)|ABC]] programming language | [[Guido van Rossum]] began working on Python in the late 1980s as a successor to the [[ABC (programming language)|ABC]] programming language. Python 3.0, released in 2008, was a major revision and not completely [[backward-compatible]] with earlier versions. Beginning with Python 3.5,<ref>{{cite web |title=PEP 484 – Type Hints |url=https://peps.python.org/pep-0484/ |website=Python Enhancement Proposals |access-date=27 October 2025 |language=en}}</ref> capabilities and keywords for typing were added to the language, allowing optional [[static typing]].<ref>{{Cite web |title=mypy – Optional Static Typing for Python |url=https://mypy-lang.org/ |access-date=17 August 2025 |website=mypy-lang.org}}</ref> Currently only versions in the 3.x series are supported. | ||
Python | Python has gained widespread use in the [[machine learning]] community.<ref>{{Cite web |title=Stack Overflow Developer Survey 2022 |url=https://survey.stackoverflow.co/2022/ |url-status=live |archive-url=https://web.archive.org/web/20220627175307/https://survey.stackoverflow.co/2022/ |archive-date=27 June 2022 |access-date=12 August 2022 |website=Stack Overflow |language=en}}</ref><ref>{{Cite web |title=The State of Developer Ecosystem in 2020 Infographic |url=https://www.jetbrains.com/lp/devecosystem-2020/ |url-status=live |archive-url=https://web.archive.org/web/20210301062411/https://www.jetbrains.com/lp/devecosystem-2020/ |archive-date=1 March 2021 |access-date=5 March 2021 |website=JetBrains |language=en}}</ref><ref name="tiobecurrent">{{cite web |title=TIOBE Index |url=https://www.tiobe.com/tiobe-index/ |url-status=live |archive-url=https://web.archive.org/web/20180225101948/https://www.tiobe.com/tiobe-index/ |archive-date=25 February 2018 |access-date=3 January 2023 |publisher=TIOBE |quote=The TIOBE Programming Community index is an indicator of the popularity of programming languages}} Updated as required.</ref><ref>{{Cite journal |last1=Healy |first1=John |last2=McInnes |first2=Leland |last3=Weir |first3=Colin |date=2017 |title=Bridging the Cyber-Analysis Gap: The Democratization of Data Science |journal=The Cyber Defense Review |volume=2 |issue=1 |pages=109–118 |issn=2474-2120 |jstor=26267404 |quote="Python is the lingua franca of data science and machine learning."}}</ref> It is widely taught as an introductory programming language.<ref>{{Cite journal |last1=Sultana |first1=Simon G. |last2=Reed |first2=Philip A. |date=2017 |title=Curriculum for an Introductory Computer Science Course: Identifying Recommendations from Academia and Industry |journal=The Journal of Technology Studies |volume=43 |issue=2 |pages=80–92 |doi=10.21061/jots.v43i2.a.3 |issn=1071-6084 |jstor=90023144}}</ref> Since 2003, Python has consistently ranked in the top ten of the most popular programming languages in the [[TIOBE Programming Community Index]], which ranks based on searches in 24 platforms.<ref>{{cite web |title=TIOBE Index |publisher=TIOBE |url=https://www.tiobe.com/tiobe-index/ |access-date=3 January 2023 |quote=The TIOBE Programming Community index is an indicator of the popularity of programming languages |archive-date=25 February 2018 |archive-url=https://web.archive.org/web/20180225101948/https://www.tiobe.com/tiobe-index/ |url-status=live}}</ref> | ||
==History== | == History == | ||
{{Main|History of Python}} | {{Main|History of Python}} | ||
[[File:Guido van Rossum in PyConUS24.jpg|thumb|311x311px|The designer of Python, [[Guido van Rossum]], at PyCon US 2024]] | [[File:Guido van Rossum in PyConUS24.jpg|thumb|311x311px|The designer of Python, [[Guido van Rossum]], at [[PyCon]] US 2024]] | ||
Python was conceived in the late 1980s<ref name="venners-interview-pt-1"/> by [[Guido van Rossum]] at [[Centrum Wiskunde & Informatica]] (CWI) in the [[Netherlands]] | Python was conceived in the late 1980s<ref name="venners-interview-pt-1" /> by [[Guido van Rossum]] at [[Centrum Wiskunde & Informatica]] (CWI) in the [[Netherlands]].<ref name="timeline-of-python" /> It was designed as a successor to the [[ABC (programming language)|ABC]] programming language, which was inspired by [[SETL]],<ref name="AutoNT-12" /> capable of [[exception handling]] and interfacing with the [[Amoeba (operating system)|Amoeba]] operating system.<ref name="faq-created" /> Python implementation began in December 1989.<ref name="timeline-of-python" /> Van Rossum first released it in 1991 as Python 0.9.0.<ref name="timeline-of-python" /> Van Rossum assumed sole responsibility for the project, as the lead developer, until 12 July 2018, when he announced his "permanent vacation" from responsibilities as Python's "[[benevolent dictator for life]]" (BDFL); this title was bestowed on him by the Python community to reflect his long-term commitment as the project's chief decision-maker.<ref name="lj-bdfl-resignation" /> (He has since come out of retirement and is self-titled "BDFL-emeritus"<!-- on his Twitter-->.) In January 2019, active Python core developers elected a five-member Steering Council to lead the project.<ref>{{cite web |last1=Smith |first1=Nathaniel J. |last2=Durbin |first2=Ee |title=PEP 8100 – January 2019 Steering Council election |url=https://peps.python.org/pep-8100/ |url-status=live |archive-url=https://web.archive.org/web/20200604235027/https://www.python.org/dev/peps/pep-8100/ |archive-date=4 June 2020 |access-date=4 May 2019 |website=Python Enhancement Proposals (PEPs) |publisher=Python Software Foundation}}</ref><ref>{{Cite web |author=The Python core team and community |title=PEP 13 – Python Language Governance |url=https://peps.python.org/pep-0013/ |url-status=live |archive-url=https://web.archive.org/web/20210527000035/https://www.python.org/dev/peps/pep-0013/ |archive-date=27 May 2021 |access-date=25 August 2021 |website=Python Enhancement Proposals (PEPs) |language=en}}</ref> | ||
The name ''Python'' derives from the British comedy series [[Monty Python's Flying Circus]].<ref name=":0">{{Cite book |last1=Briggs |first1=Jason R. |url=https://archive.org/details/pythonforkidspla0000brig |title=Python for kids: a playful introduction to programming |last2=Lipovača |first2=Miran |date=2013 |publisher=No Starch Press |isbn=978-1-59327-407-8 |location=San Francisco, California, USA |lccn=2012044047 |oclc=825076499 |ol=26119645M}}</ref> (See {{section link||Naming}}.) | |||
" | |||
Python 2.0 was released on 16 October 2000, featuring many new features such as [[list comprehension]]s, [[cycle detection|cycle-detecting]] garbage collection, [[reference counting]], and [[Unicode]] support.<ref name="newin-2.0" /> Python 2.7's [[end-of-life product|end-of-life]] was initially set for 2015, and then postponed to 2020 out of concern that a large body of existing code could not easily be forward-ported to Python 3.<ref>{{cite web |last=Peterson |first=Benjamin |title=PEP 373 – Python 2.7 Release Schedule |url=https://legacy.python.org/dev/peps/pep-0373/ |url-status=live |archive-url=https://web.archive.org/web/20200519075520/https://legacy.python.org/dev/peps/pep-0373/ |archive-date=19 May 2020 |access-date=9 January 2017 |work=python.org}}</ref><ref>{{cite web |last=Coghlan |first=Alyssa |title=PEP 466 – Network Security Enhancements for Python 2.7.x |url=https://peps.python.org/pep-0466/ |url-status=live |archive-url=https://web.archive.org/web/20200604232833/https://www.python.org/dev/peps/pep-0466/ |archive-date=4 June 2020 |access-date=9 January 2017 |website=Python Enhancement Proposals (PEPs)}}</ref> It no longer receives security patches or updates.<ref>{{Cite web |title=Sunsetting Python 2 |url=https://www.python.org/doc/sunset-python-2/ |url-status=live |archive-url=https://web.archive.org/web/20200112080903/https://www.python.org/doc/sunset-python-2/ |archive-date=12 January 2020 |access-date=22 September 2019 |website=Python.org |language=en}}</ref><ref>{{Cite web |last=Peterson |first=Benjamin |title=PEP 373 – Python 2.7 Release Schedule |url=https://peps.python.org/pep-0373/ |url-status=live |archive-url=https://web.archive.org/web/20200113033257/https://www.python.org/dev/peps/pep-0373/ |archive-date=13 January 2020 |access-date=22 September 2019 |website=Python Enhancement Proposals (PEPs) |language=en}}</ref> While Python 2.7 and older versions are officially unsupported, a different unofficial Python implementation, [[PyPy]], continues to support Python 2, i.e., "2.7.18+" (plus 3.11<!-- PyPy docs in Nov 2025: "Python 2.7.18 and 3.11.11", not mentioning later 3.11.14 -->), with the plus signifying (at least some) "[[backporting|backported]] security updates".<ref>{{Cite web |last=mattip |date=25 December 2023 |title=PyPy v7.3.14 release |url=https://www.pypy.org/posts/2023/12/pypy-v7314-release.html |url-status=live |archive-url=https://web.archive.org/web/20240105132820/https://www.pypy.org/posts/2023/12/pypy-v7314-release.html |archive-date=5 January 2024 |access-date=5 January 2024 |website=PyPy |language=en}}</ref> | |||
--> | |||
Python 3. | Python 3.0 was released on 3 December 2008, and was a major revision and not completely [[backward-compatible]] with earlier versions, with some new semantics and changed syntax. Python 2.7.18, released in 2020, was the last release of Python 2.<ref>{{Cite web |last=Peterson |first=Benjamin |date=20 April 2020 |title=Python 2.7.18, the last release of Python 2 |url=https://pythoninsider.blogspot.com/2020/04/python-2718-last-release-of-python-2.html |url-status=live |archive-url=https://web.archive.org/web/20200426204118/https://pythoninsider.blogspot.com/2020/04/python-2718-last-release-of-python-2.html |archive-date=26 April 2020 |access-date=27 April 2020 |website=Python Insider}}</ref> Several releases in the Python 3.x series have added new syntax to the language, and made a few (considered very minor) backward-incompatible changes. | ||
{{As of|2025|11}}, Python 3.14.0 is the latest stable release, and Python 3.13.9 was released a week later, all older 3.x versions had a security update down to Python 3.9.24 then again with 3.9.25, the final version in 3.9 series. Python 3.10 is, since November 2025, the oldest supported branch.<ref>{{Cite web |title=Status of Python versions |url=https://devguide.python.org/versions/ |access-date=12 November 2025 |website=Python Developer's Guide |language=en}}</ref> Python 3.15 has an alpha released, and Android has a official downloadable executable available for Python 3.14. Releases receive two years of full support followed by three years of security support. | |||
==Design philosophy and features== | ==Design philosophy and features== | ||
Python is a [[multi-paradigm programming language]]. Object-oriented programming and structured programming are fully supported, and many of their features support functional programming and [[aspect-oriented programming]] | Python is a [[multi-paradigm programming language]]. Object-oriented programming and structured programming are fully supported, and many of their features support functional programming and [[aspect-oriented programming]] – including [[metaprogramming]]<ref name=AutoNT-13/> and [[metaobject]]s.<ref name=AutoNT-14/> Many other paradigms are supported via extensions, including [[design by contract]]<ref name=AutoNT-15/><ref name=AutoNT-16/> and [[logic programming]].<ref name=AutoNT-17/> Python is often referred to as a ''[[glue language|<nowiki/>'glue language']]''<ref>{{cite web |title=Glue it all together with Python |url=https://www.python.org/doc/essays/omg-darpa-mcc-position/ |access-date=2024-09-30 |website=Python.org |language=en}}</ref> because it is purposely designed to be able to integrate components written in other languages. | ||
Python uses dynamic typing and a combination of [[reference counting]] and a cycle-detecting garbage collector for [[memory management]].<ref name= | Python uses dynamic typing and a combination of [[reference counting]] and a cycle-detecting garbage collector for [[memory management]].<ref name=Reference_counting>{{cite web |title=Reference counts |department=Extending and embedding the Python interpreter |website=Docs.python.org |language=en |url=https://docs.python.org/extending/extending.html#reference-counts |url-status=live |access-date=5 June 2020 |quote=Since Python makes heavy use of <code>malloc()</code> and <code>free()}</code>, it needs a strategy to avoid memory leaks as well as the re‑use of freed memory. The method chosen is called ''reference counting''. |archive-url=https://web.archive.org/web/20121018063230/http://docs.python.org/extending/extending.html#reference-counts |archive-date=18 October 2012 }}</ref> It uses dynamic [[Name resolution (programming languages)|name resolution]] ([[late binding]]), which binds method and variable names during program execution. | ||
Python's design offers some support for functional programming in the [[Lisp (programming language)|Lisp]] tradition. It has {{ | Python's design offers some support for functional programming in the "[[Lisp (programming language)|Lisp]] tradition". It has {{code|filter}}, {{code|map}}, and {{code|reduce}} functions; [[list comprehension]]s, [[associative array|dictionaries]], [[set (mathematics)|sets]], and [[generator (computer programming)|generator]] expressions.<ref name=AutoNT-59/> The standard library has two modules ({{codes|itertools}} and {{codes|functools}}) that implement functional tools borrowed from [[Haskell]] and [[Standard ML]].<ref name=AutoNT-18/> | ||
Python's core philosophy is summarized in the [[Zen of Python]] (PEP 20), which includes aphorisms such as these:<ref name= | Python's core philosophy is summarized in the [[Zen of Python]] (PEP 20) written by [[Tim Peters (software engineer)|Tim Peters]], which includes aphorisms such as these:<ref name=PEP20/> | ||
* Explicit is better than implicit. | * Explicit is better than implicit. | ||
* Simple is better than complex. | * Simple is better than complex. | ||
* Readability counts. | * Readability counts. | ||
* Special cases aren't special enough to break the rules. | |||
* Although practicality beats purity. | |||
* Errors should never pass silently. | |||
* Unless explicitly silenced. | |||
* There should be one-- and preferably only one --obvious way to do it. | |||
<!-- Note this isn't a full list, just some of the more significant aphorisms --> | |||
However, Python | However, Python has received criticism for violating these principles and adding unnecessary language bloat.<ref name=Python-Changes-2014>{{cite web |last=Lutz |first=Mark |date=January 2022 |website=Learning Python |title=Python changes 2014+ |url=https://learning-python.com/python-changes-2014-plus.html |url-status=live |access-date=25 February 2024 |archive-url=https://web.archive.org/web/20240315075935/https://learning-python.com/python-changes-2014-plus.html |archive-date=15 March 2024 }}</ref> Responses to these criticisms note that the Zen of Python is a guideline rather than a rule.<ref name=Confusion-regarding-a-rule-in-the-Zen-of-Python>{{cite web |url=https://discuss.python.org/t/confusion-regarding-a-rule-in-the-zen-of-python/15927 |title=Confusion regarding a rule in 'the Zen of Python' |date=2022-05-03 |department=Discussions |series=Python help |website=Python.org |access-date=2024-02-25 |archive-date=25 February 2024 |archive-url=https://web.archive.org/web/20240225221142/https://discuss.python.org/t/confusion-regarding-a-rule-in-the-zen-of-python/15927 |url-status=live}}</ref> The addition of some new features had been controversial: Guido van Rossum resigned as ''Benevolent Dictator for Life'' after conflict about adding the assignment expression operator in {{nobr|Python 3.8 .}}<ref name=The-Most-Controversial-Python-Walrus-Operator>{{cite web |last=Ambi |first=Chetan |date=2021-07-04 |title=The most controversial Python 'walrus operator' |website=Python simplified (pythonsimplified.com) |url=https://pythonsimplified.com/the-most-controversial-python-walrus-operator/ |url-status=live |access-date=2024-02-05 |archive-url=https://web.archive.org/web/20230827154931/https://pythonsimplified.com/the-most-controversial-python-walrus-operator/ |archive-date=27 August 2023 }}</ref><ref name=The-Controversy-Behind-The-Walrus-Operator-in-Python>{{cite web |last=Grifski |first=Jeremy |date=2020-05-24 |title=The controversy behind the 'walrus operator' in Python |website=The Renegade Coder (therenegadecoder.com) |url=https://therenegadecoder.com/code/the-controversy-behind-the-walrus-operator-in-python/ |url-status=live |access-date=2024-02-25 |archive-url=https://web.archive.org/web/20231228135749/https://therenegadecoder.com/code/the-controversy-behind-the-walrus-operator-in-python/ |archive-date=28 December 2023 }}</ref> | ||
Nevertheless, rather than building all functionality into its core, Python was designed to be highly [[extensible]] via modules. This compact modularity has made it particularly popular as a means of adding programmable interfaces to existing applications. Van Rossum's vision of a small core language with a large standard library and easily extensible interpreter stemmed from his frustrations with ABC, which represented the opposite approach.<ref name= | Nevertheless, rather than building all functionality into its core, Python was designed to be highly [[extensible]] via modules. This compact modularity has made it particularly popular as a means of adding programmable interfaces to existing applications. Van Rossum's vision of a small core language with a large standard library and easily extensible interpreter stemmed from his frustrations with ABC, which represented the opposite approach.<ref name=venners-interview-pt-1/> | ||
Python claims to strive for a simpler, less-cluttered syntax and grammar, while giving developers a choice in their coding methodology. In contrast to [[Perl]]'s motto "[[there is more than one way to do it]]", Python advocates an approach where "there should be | Python claims to strive for a simpler, less-cluttered syntax and grammar, while giving developers a choice in their coding methodology. Python lacks do while loops, which [[Guido Van Rossum|Rossum]] considered harmful.<ref>{{cite web|url=https://mail.python.org/pipermail/python-ideas/2013-June/021610.html|title=[Python-ideas] PEP 315: do-while |date=26 June 2013 }}</ref> In contrast to [[Perl]]'s motto "[[there is more than one way to do it]]", Python advocates an approach where "there should be one – and preferably only one – obvious way to do it".<!-- removed comment with specious demand to leave punctuation contrary to Wikipedia MOS unchanged: Reason given, to duplicate lack of spaces in quote, is a grotesquely false justification. --><ref name=PEP20/> In practice, however, Python provides many ways to achieve a given goal. There are at least three ways to format a string literal, with no certainty as to which one a programmer should use.<ref name=Python-String-Formatting-Best-Practices>{{cite web |last=Bader |first=Dan |title=Python string formatting best practices |website=Real Python (realpython.com) |url=https://realpython.com/python-string-formatting/ |url-status=live |access-date=2024-02-25 |archive-url=https://web.archive.org/web/20240218083506/https://realpython.com/python-string-formatting/ |archive-date=18 February 2024 }}</ref> [[Alex Martelli]] is a [[Fellow]] at the [[Python Software Foundation]] and Python book author; he wrote that "To describe something as 'clever' is ''not'' considered a compliment in the Python culture."<ref name=AutoNT-19/> | ||
Python's developers | Python's developers typically prioritise readability over performance. For example, they reject patches to non-critical parts of the [[CPython]] reference implementation that would offer increases in speed that do not justify the cost of clarity and readability.<ref name="AutoNT-20"/>{{Failed verification|date=August 2025|reason=The referenced source did not mention that information. A better source should be found.}} Execution speed can be improved by moving speed-critical functions to extension modules written in languages such as [[C (programming language)|C]], or by using a [[just-in-time compiler]] like [[PyPy]]. Also, it is possible to transpile to other languages. However, this approach either fails to achieve the expected speed-up, since Python is a very [[dynamic language]], or only a restricted subset of Python is compiled (with potential minor semantic changes).<ref name=PyJL/> | ||
Python | Python is meant to be a fun language to use. This goal is reflected in the name – a tribute to the British comedy group [[Monty Python]]<ref name=whyname/> – and in playful approaches to some tutorials and reference materials. For instance, some code examples use the terms "spam" and "eggs" (in reference to [[Spam (Monty Python)|a Monty Python sketch]]), rather than the typical terms [[foobar|"foo" and "bar"]].<ref>{{cite web |title=15 ways Python is a powerful force on the web |url=https://insidetech.monster.com/training/articles/8114-15-ways-python-is-a-powerful-force-on-the-web |access-date=3 July 2018 |archive-url=https://web.archive.org/web/20190511065650/http://insidetech.monster.com/training/articles/8114-15-ways-python-is-a-powerful-force-on-the-web |archive-date=11 May 2019 }}</ref><ref name=pprint-doc>{{cite web |title=<code>pprint</code> – data pretty printer – {{nobr|Python 3.11.0}} documentation |website=docs.python.org |quote=<code>stuff {{=}} ['spam', 'eggs', 'lumberjack', 'knights', 'ni']</code> |url=https://docs.python.org/3/library/pprint.html |url-status=live |access-date=2022-11-05 |archive-url=https://web.archive.org/web/20210122224848/https://docs.python.org/3/library/pprint.html |archive-date=22 January 2021 }}</ref> | ||
A common [[neologism]] in the Python community is ''pythonic'', which has a broad range of meanings related to program style: Pythonic code may use Python [[Programming idiom|idioms]] well; be natural or show fluency in the language; or conform with Python's minimalist philosophy and emphasis on readability.<ref>{{cite web |title=Code style |department=The hitchhiker's guide to Python |website=docs.python-guide.org |url=https://docs.python-guide.org/writing/style |url-status=live |access-date=20 January 2021 |archive-url=https://web.archive.org/web/20210127154341/https://docs.python-guide.org/writing/style/ |archive-date=27 January 2021 }}</ref> | |||
==Syntax and semantics== | ==Syntax and semantics== | ||
{{Main|Python syntax and semantics}} | {{Main|Python syntax and semantics}} | ||
Python is meant to be an easily readable language. Its formatting is visually uncluttered and often uses English keywords where other languages use punctuation. Unlike many other languages, it does not use [[curly bracket programming language|curly brackets]] to delimit blocks, and semicolons after statements are allowed but rarely used. It has fewer syntactic exceptions and special cases than [[C (programming language)|C]] or [[Pascal (programming language)|Pascal]].<ref name="AutoNT-52"/> | Python is meant to be an easily readable language. Its formatting is visually uncluttered and often uses English keywords where other languages use punctuation. Unlike many other languages, it does not use [[curly bracket programming language|curly brackets]] to delimit blocks, and semicolons after statements are allowed but rarely used. It has fewer syntactic exceptions and special cases than [[C (programming language)|C]] or [[Pascal (programming language)|Pascal]].<ref name="AutoNT-52"/> | ||
===Indentation=== | ===Indentation=== | ||
{{ | {{Further|Python syntax and semantics#Indentation}} | ||
Python uses [[whitespace character|whitespace]] indentation, rather than curly brackets or keywords, to delimit [[block (programming)|blocks]]. An increase in indentation comes after certain statements; a decrease in indentation signifies the end of the current block.<ref name="AutoNT-53"/> Thus, the program's visual structure accurately represents its semantic structure.<ref name=guttag>{{Cite book |publisher=MIT Press |isbn=978-0-262-52962-4 |last=Guttag |first=John V. |title=Introduction to Computation and Programming Using Python: With Application to Understanding Data |date=12 August 2016}}</ref> This feature is sometimes termed the [[off-side rule]]. Some other languages use indentation this way; but in most, indentation has no semantic meaning. The recommended indent size is four spaces.<ref>{{Cite web|url=https://www.python.org/dev/peps/pep-0008/|title=PEP 8 – Style Guide for Python Code|website=Python | Python uses [[whitespace character|whitespace]] indentation, rather than curly brackets or keywords, to delimit [[block (programming)|blocks]]. An increase in indentation comes after certain statements; a decrease in indentation signifies the end of the current block.<ref name="AutoNT-53"/> Thus, the program's visual structure accurately represents its semantic structure.<ref name=guttag>{{Cite book |publisher=MIT Press |isbn=978-0-262-52962-4 |last=Guttag |first=John V. |title=Introduction to Computation and Programming Using Python: With Application to Understanding Data |date=12 August 2016}}</ref> This feature is sometimes termed the [[off-side rule]]. Some other languages use indentation this way; but in most, indentation has no semantic meaning. The recommended indent size is four spaces.<ref name="pep8">{{Cite web |first1=Guido |last1= van Rossum |first2= Barry |last2=Warsaw |url=https://www.python.org/dev/peps/pep-0008/|title=PEP 8 – Style Guide for Python Code|website=Python Enhancement Proposals (PEPs)|access-date=26 March 2019|archive-date=17 April 2019|archive-url=https://web.archive.org/web/20190417223549/https://www.python.org/dev/peps/pep-0008/|url-status=live}}</ref> | ||
===Statements and control flow=== | ===Statements and control flow=== | ||
Python's [[statement (computer science)|statements]] include the following: | Python's [[statement (computer science)|statements]] include the following: | ||
* The [[Assignment (computer science)|assignment]] statement, using a single equals sign <code>=</code> | * The [[Assignment (computer science)|assignment]] statement, using a single equals sign <code>=</code> | ||
* The <code>[[if-then-else|if]]</code> statement, which conditionally executes a block of code, along with <code>else</code> and <code>elif</code> (a contraction of <code>else if</code>) | * The <code>[[if-then-else|if]]</code> statement, which conditionally executes a block of code, along with <code>[[Conditional (computer programming)#If–then(–else)|else]]</code> and <code>elif</code> (a contraction of <code>[[Conditional (computer programming)#Else if|else if]]</code>) | ||
* The <code>[[Foreach#Python|for]]</code> statement, which iterates over an ''iterable'' object, capturing each element to a | * The <code>[[Foreach#Python|for]]</code> statement, which iterates over an ''iterable'' object, capturing each element to a variable for use by the attached block; the variable is not deleted when the loop finishes | ||
* The <code>[[While loop#Python|while]]</code> statement, which executes a block of code as long as boolean condition is true | * The <code>[[While loop#Python|while]]</code> statement, which executes a block of code as long as boolean condition is true | ||
* The <code>[[Exception handling syntax#Python|try]]</code> statement, which allows exceptions raised in its attached code block to be caught and handled by <code>except</code> clauses (or new syntax <code>except*</code> in Python 3.11 for exception groups<ref>{{Cite web |title=8. Errors and Exceptions – Python 3.12.0a0 documentation |url=https://docs.python.org/3.11/tutorial/errors.html |access-date=2022-05-09 |website=docs.python.org |archive-date=9 May 2022 |archive-url=https://web.archive.org/web/20220509145745/https://docs.python.org/3.11/tutorial/errors.html |url-status=live}}</ref> | * The <code>[[Exception handling syntax#Python|try]]</code> statement, which allows exceptions raised in its attached code block to be caught and handled by <code>except</code> clauses (or new syntax <code>except*</code> in Python 3.11 for exception groups);<ref>{{Cite web |title=8. Errors and Exceptions – Python 3.12.0a0 documentation |url=https://docs.python.org/3.11/tutorial/errors.html |access-date=2022-05-09 |website=docs.python.org |archive-date=9 May 2022 |archive-url=https://web.archive.org/web/20220509145745/https://docs.python.org/3.11/tutorial/errors.html |url-status=live}}</ref> the <code>try</code> statement also ensures that clean-up code in a <code>finally</code> block is always run regardless of how the block exits | ||
* The <code>raise</code> statement, used to raise a specified exception or re-raise a caught exception | * The <code>raise</code> statement, used to raise a specified exception or re-raise a caught exception | ||
* The <code>class</code> statement, which executes a block of code and attaches its local namespace to a [[class (computer science)|class]], for use in object-oriented programming | * The <code>class</code> statement, which executes a block of code and attaches its local namespace to a [[class (computer science)|class]], for use in object-oriented programming | ||
| Line 211: | Line 142: | ||
* Python uses the <code>+</code> operator for string concatenation. The language uses the <code>*</code> operator for duplicating a string a specified number of times. | * Python uses the <code>+</code> operator for string concatenation. The language uses the <code>*</code> operator for duplicating a string a specified number of times. | ||
* The <code>@</code> infix operator<!-- was introduced in Python 3.5--> is intended to be used by libraries such as [[NumPy]] for [[matrix multiplication]].<ref name=PEP465>{{cite web |title=PEP 0465 – A dedicated infix operator for matrix multiplication |url=https://www.python.org/dev/peps/pep-0465/ |website=python.org |access-date=1 January 2016 |archive-date=4 June 2020 |archive-url=https://web.archive.org/web/20200604224255/https://www.python.org/dev/peps/pep-0465/ |url-status=live}}</ref><ref name=Python3.5Changelog>{{cite web |title=Python 3.5.1 Release and Changelog |url=https://www.python.org/downloads/release/python-351/ |website=python.org |access-date=1 January 2016 |archive-date=14 May 2020 |archive-url=https://web.archive.org/web/20200514034938/https://www.python.org/downloads/release/python-351/ |url-status=live}}</ref> | * The <code>@</code> infix operator<!-- was introduced in Python 3.5--> is intended to be used by libraries such as [[NumPy]] for [[matrix multiplication]].<ref name=PEP465>{{cite web |title=PEP 0465 – A dedicated infix operator for matrix multiplication |url=https://www.python.org/dev/peps/pep-0465/ |website=python.org |access-date=1 January 2016 |archive-date=4 June 2020 |archive-url=https://web.archive.org/web/20200604224255/https://www.python.org/dev/peps/pep-0465/ |url-status=live}}</ref><ref name=Python3.5Changelog>{{cite web |title=Python 3.5.1 Release and Changelog |url=https://www.python.org/downloads/release/python-351/ |website=python.org |access-date=1 January 2016 |archive-date=14 May 2020 |archive-url=https://web.archive.org/web/20200514034938/https://www.python.org/downloads/release/python-351/ |url-status=live}}</ref> | ||
* The syntax <code>:=</code>, called the "walrus operator", was introduced in Python 3.8. This operator assigns values to variables as part of a larger expression.<ref name=Python3.8Changelog>{{cite web |title=What's New in Python 3.8 |url=https://docs.python.org/3.8/whatsnew/3.8.html |access-date=14 October 2019 |archive-date=8 June 2020 |archive-url=https://web.archive.org/web/20200608124345/https://docs.python.org/3.8/whatsnew/3.8.html |url-status=live}}</ref> | * The syntax <code>:=</code>, called the "{{va|walrus operator}}", was introduced in Python 3.8. This operator assigns values to variables as part of a larger expression.<ref name=Python3.8Changelog>{{cite web |title=What's New in Python 3.8 |url=https://docs.python.org/3.8/whatsnew/3.8.html |access-date=14 October 2019 |archive-date=8 June 2020 |archive-url=https://web.archive.org/web/20200608124345/https://docs.python.org/3.8/whatsnew/3.8.html |url-status=live}}</ref> | ||
* In Python, <code>==</code> compares two objects by value. Python's <code>is</code> operator may be used to compare object identities (i.e., comparison by reference), and comparisons may be chained—for example, {{code|lang=python|code=a <= b <= c}}. | * In Python, <code>==</code> compares two objects by value. Python's <code>is</code> operator may be used to compare object identities (i.e., comparison by reference), and comparisons may be chained—for example, {{code|lang=python|code=a <= b <= c}}. | ||
* Python uses <code>and</code>, <code>or</code>, and <code>not</code> as Boolean operators. | * Python uses <code>and</code>, <code>or</code>, and <code>not</code> as Boolean operators. | ||
| Line 233: | Line 164: | ||
A statement cannot be part of an expression; because of this restriction, expressions such as list and <code>dict</code> comprehensions (and lambda expressions) cannot contain statements. As a particular case, an assignment statement such as {{code|lang=python|code=a = 1}} cannot be part of the conditional expression of a conditional statement. | A statement cannot be part of an expression; because of this restriction, expressions such as list and <code>dict</code> comprehensions (and lambda expressions) cannot contain statements. As a particular case, an assignment statement such as {{code|lang=python|code=a = 1}} cannot be part of the conditional expression of a conditional statement. | ||
===Typing=== | ===Typing=== | ||
| Line 245: | Line 173: | ||
Before version 3.0, Python had two kinds of classes, both using the same syntax: ''old-style'' and ''new-style''.<ref name="classy"/> Current Python versions support the semantics of only the new style. | Before version 3.0, Python had two kinds of classes, both using the same syntax: ''old-style'' and ''new-style''.<ref name="classy"/> Current Python versions support the semantics of only the new style. | ||
Python supports [[optional typing|optional type annotations]].<ref name="type_hint-PEP"/><ref>{{Cite web |title=PEP 484 – Type Hints {{!}} peps.python.org |url=https://peps.python.org/pep-0484/ |access-date=2023-11-29 |website=peps.python.org |archive-date=27 November 2023 |archive-url=https://web.archive.org/web/20231127205023/https://peps.python.org/pep-0484/ |url-status=live}}</ref> These annotations are not enforced by the language, but may be used by external tools such as '''mypy''' to catch errors.<ref>{{cite web |title=typing — Support for type hints |url=https://docs.python.org/3/library/typing.html |website=Python documentation |publisher=Python Software Foundation |access-date=22 December 2023 |archive-date=21 February 2020 |archive-url=https://web.archive.org/web/20200221184042/https://docs.python.org/3/library/typing.html |url-status=live}}</ref><ref>{{cite web |url=http://mypy-lang.org/ |title=mypy – Optional Static Typing for Python |access-date=28 January 2017 |archive-date=6 June 2020 |archive-url=https://web.archive.org/web/20200606192012/http://mypy-lang.org/ |url-status=live}}</ref> Mypy | Python supports [[optional typing|optional type annotations]].<ref name="type_hint-PEP"/><ref>{{Cite web |title=PEP 484 – Type Hints {{!}} peps.python.org |url=https://peps.python.org/pep-0484/ |access-date=2023-11-29 |website=peps.python.org |archive-date=27 November 2023 |archive-url=https://web.archive.org/web/20231127205023/https://peps.python.org/pep-0484/ |url-status=live}}</ref> These annotations are not enforced by the language, but may be used by external tools such as '''mypy''' to catch errors. Python includes a module <code>typing</code> including several type names for type annotations.<ref>{{cite web |title=typing — Support for type hints |url=https://docs.python.org/3/library/typing.html |website=Python documentation |publisher=Python Software Foundation |access-date=22 December 2023 |archive-date=21 February 2020 |archive-url=https://web.archive.org/web/20200221184042/https://docs.python.org/3/library/typing.html |url-status=live}}</ref><ref>{{cite web |url=http://mypy-lang.org/ |title=mypy – Optional Static Typing for Python |access-date=28 January 2017 |archive-date=6 June 2020 |archive-url=https://web.archive.org/web/20200606192012/http://mypy-lang.org/ |url-status=live}}</ref> Also, Mypy supports a Python compiler called mypyc, which leverages type annotations for optimization.<ref>{{cite web |title=Introduction |url=https://mypyc.readthedocs.io/en/latest/introduction.html |website=mypyc.readthedocs.io |access-date=22 December 2023 |archive-date=22 December 2023 |archive-url=https://web.archive.org/web/20231222000457/https://mypyc.readthedocs.io/en/latest/introduction.html |url-status=live}}</ref> | ||
{|class="wikitable" | {|class="wikitable" | ||
| Line 273: | Line 201: | ||
| immutable | | immutable | ||
| [[Complex number]] with real and imaginary parts | | [[Complex number]] with real and imaginary parts | ||
| {{code|lang=python|3+2.7j}}<br />{{code|lang=python|3 + 2.7j}} | | {{code|lang=python|3+2.7j}}<br />{{code|lang=python|3 + 2.7j}}<br />{{code|lang=python|5j}} | ||
|- | |- | ||
| <code>dict</code> | | <code>dict</code> | ||
| Line 303: | Line 231: | ||
| immutable | | immutable | ||
| Unordered [[set (computer science)|set]], contains no duplicates; can contain mixed types, if hashable | | Unordered [[set (computer science)|set]], contains no duplicates; can contain mixed types, if hashable | ||
| {{code|lang=python|frozenset({4.0, 'string', True})}} | |||
{{code|lang=python|frozenset()}} | |||
|- | |- | ||
| <code>int</code> | | <code>int</code> | ||
| Line 340: | Line 269: | ||
| {{code|lang=python|'Wikipedia'}}<br />{{code|lang=python|"Wikipedia"}}<syntaxhighlight lang="python">"""Spanning | | {{code|lang=python|'Wikipedia'}}<br />{{code|lang=python|"Wikipedia"}}<syntaxhighlight lang="python">"""Spanning | ||
multiple | multiple | ||
lines""" | lines"""</syntaxhighlight> | ||
</syntaxhighlight> | |||
|- | |- | ||
| <code>tuple</code> | | <code>tuple</code> | ||
| Line 353: | Line 278: | ||
===Arithmetic operations=== | ===Arithmetic operations=== | ||
Python includes conventional symbols for arithmetic operators (<code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>), the floor-division operator <code>//</code>, and the [[modulo operation|modulo operator]] <code>%</code>. (With the | Python includes conventional symbols for arithmetic operators (<code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>), the floor-division operator <code>//</code>, and the [[modulo operation|modulo operator]] <code>%</code>. (With the modulo operator, a remainder can be negative,<!--unlike in C language depending on compiler,<ref>{{Cite web|url=https://stackoverflow.com/questions/11720656/modulo-operation-with-negative-numbers/42131603|title=c – Modulo operation with negative numbers|quote=Note that, in C89, whether the result round upward or downward is implementation-defined.|website=Stack Overflow|access-date=25 September 2019}}</ref>--> e.g., <code>4 % -3 == -2</code>.) Also, Python offers the <code>**</code> symbol for [[exponentiation]], e.g. <code>5**3 == 125</code> and <code>9**0.5 == 3.0</code>. Also, it offers the matrix‑multiplication operator <code>@</code> .<ref>{{cite web |url=https://legacy.python.org/dev/peps/pep-0465/ |title=PEP 465 – A dedicated infix operator for matrix multiplication |work=python.org |access-date=3 July 2018 |archive-date=29 May 2020 |archive-url=https://web.archive.org/web/20200529200310/https://legacy.python.org/dev/peps/pep-0465/ |url-status=live}}</ref> These operators work as in traditional mathematics; with the same [[order of operations|precedence rules]], the [[infix notation|infix]] operators <code>+</code> and <code>-</code> can also be [[unary operation|unary]], to represent positive and negative numbers respectively. | ||
Division between integers produces floating-point results. The behavior of division has changed significantly over time:<ref name="pep0238"/> | Division between integers produces floating-point results. The behavior of division has changed significantly over time:<ref name="pep0238"/> | ||
* The current version of Python (i.e., since 3.0) changed <code> | * The current version of Python (i.e., since 3.0) changed the <code>/</code> operator to always represent floating-point division, e.g., {{code|class=nowrap|2=python|1=5/2 == 2.5}}. | ||
* The floor division <code>//</code> operator was introduced | * The floor division <code>//</code> operator was introduced, meaning that <code>7//3 == 2</code>, <code>-7//3 == -3</code>, <code>7.5//3 == 2.0</code>, and <code>-7.5//3 == -3.0</code>. For Python 2.7, adding the {{code|class=nowrap|2=python2|1=from __future__ import division}} statement allows a module in Python 2.7 to use Python 3.x rules for division (see above). | ||
In Python terms, the <code>/</code> operator represents ''true division'' (or simply ''division''), while the <code>//</code> operator represents ''floor division.'' Before version 3.0, the <code>/</code> operator represents ''classic division''.<ref name="pep0238"/> | In Python terms, the <code>/</code> operator represents ''true division'' (or simply ''division''), while the <code>//</code> operator represents ''floor division.'' Before version 3.0, the <code>/</code> operator represents ''classic division''.<ref name="pep0238"/> | ||
[[Rounding]] towards negative infinity, though a different method than in most languages, adds consistency to Python. For instance, this rounding implies that the equation {{code|class=nowrap|2=python|1=(a + b)//b == a//b + 1}} is always true. | [[Rounding]] towards negative infinity, though a different method than in most languages, adds consistency to Python. For instance, this rounding implies that the equation {{code|class=nowrap|2=python|1=(a + b)//b == a//b + 1}} is always true. Also, the rounding implies that the equation {{code|class=nowrap|2=python|1=b*(a//b) + a%b == a}} is valid for both positive and negative values of <code>a</code>. As expected, the result of <code>a%b</code> lies in the [[half-open interval]] [0, ''b''), where <code>b</code> is a positive integer; however, maintaining the validity of the equation requires that the result must lie in the interval (''b'', 0] when <code>b</code> is negative.<ref name="AutoNT-62"/> | ||
Python provides a <code>round</code> function for rounding a float to the nearest integer. For [[Rounding#Tie-breaking|tie-breaking]], Python 3 uses the ''round to even'' method: <code>round(1.5)</code> and <code>round(2.5)</code> both produce <code>2</code>.<ref name="AutoNT-64"/> Python versions before 3 used the [[Rounding#Rounding away from zero|round-away-from-zero]] method: <code>round(0.5)</code> is <code>1.0</code>, and <code>round(-0.5)</code> is <code>−1.0</code>.<ref name="AutoNT-63"/> | Python provides a <code>round</code> function for rounding a float to the nearest integer. For [[Rounding#Tie-breaking|tie-breaking]], Python 3 uses the ''round to even'' method: <code>round(1.5)</code> and <code>round(2.5)</code> both produce <code>2</code>.<ref name="AutoNT-64"/> Python versions before 3 used the [[Rounding#Rounding away from zero|round-away-from-zero]] method: <code>round(0.5)</code> is <code>1.0</code>, and <code>round(-0.5)</code> is <code>−1.0</code>.<ref name="AutoNT-63"/> | ||
| Line 369: | Line 294: | ||
Python uses [[arbitrary-precision arithmetic]] for all integer operations. The <code>Decimal</code> type/class in the <code>decimal</code> module provides [[decimal floating point|decimal floating-point numbers]] to a pre-defined arbitrary precision with several rounding modes.<ref name="AutoNT-88"/> The <code>Fraction</code> class in the <code>fractions</code> module provides arbitrary precision for [[rational number]]s.<ref>{{cite web|title=What's New in Python 2.6 |url=https://docs.python.org/2.6/whatsnew/2.6.html|website=Python v2.6.9 documentation |date=Oct 29, 2013 |access-date=26 September 2015|archive-date=23 December 2019|archive-url=https://web.archive.org/web/20191223213856/https://docs.python.org/2.6/whatsnew/2.6.html|url-status=live}}</ref> | Python uses [[arbitrary-precision arithmetic]] for all integer operations. The <code>Decimal</code> type/class in the <code>decimal</code> module provides [[decimal floating point|decimal floating-point numbers]] to a pre-defined arbitrary precision with several rounding modes.<ref name="AutoNT-88"/> The <code>Fraction</code> class in the <code>fractions</code> module provides arbitrary precision for [[rational number]]s.<ref>{{cite web|title=What's New in Python 2.6 |url=https://docs.python.org/2.6/whatsnew/2.6.html|website=Python v2.6.9 documentation |date=Oct 29, 2013 |access-date=26 September 2015|archive-date=23 December 2019|archive-url=https://web.archive.org/web/20191223213856/https://docs.python.org/2.6/whatsnew/2.6.html|url-status=live}}</ref> | ||
Due to Python's extensive mathematics library and the third-party library [[NumPy]], the language is frequently used for scientific scripting in tasks such as numerical data processing and manipulation.<ref>{{Cite web|url=https://www.stat.washington.edu/~hoytak/blog/whypython.html|title=10 Reasons Python Rocks for Research (And a Few Reasons it Doesn't) – Hoyt Koepke|website=University of Washington Department of Statistics |access-date=3 February 2019|archive-date=31 May 2020|archive-url=https://web.archive.org/web/20200531211840/https://www.stat.washington.edu/~hoytak/blog/whypython.html | Due to Python's extensive mathematics library and the third-party library [[NumPy]], the language is frequently used for scientific scripting in tasks such as numerical data processing and manipulation.<ref>{{Cite web|url=https://www.stat.washington.edu/~hoytak/blog/whypython.html|title=10 Reasons Python Rocks for Research (And a Few Reasons it Doesn't) – Hoyt Koepke|website=University of Washington Department of Statistics |access-date=3 February 2019|archive-date=31 May 2020|archive-url=https://web.archive.org/web/20200531211840/https://www.stat.washington.edu/~hoytak/blog/whypython.html}}</ref><ref>{{Cite web|url=https://engineering.ucsb.edu/~shell/che210d/python.pdf|title=An introduction to Python for scientific computing|last=Shell|first=Scott|date=17 June 2014|access-date=3 February 2019|archive-date=4 February 2019|archive-url=https://web.archive.org/web/20190204014642/https://engineering.ucsb.edu/~shell/che210d/python.pdf|url-status=live}}</ref> | ||
===Function syntax=== | ===Function syntax=== | ||
[[Function (computer programming)|Functions]] are created in Python by using the <code>def</code> keyword. A function is defined similarly to how it is called, by first providing the function name and then the required parameters. Here is an example of a function that prints its inputs: | [[Function (computer programming)|Functions]] are created in Python by using the <code>def</code> keyword. A function is defined similarly to how it is called, by first providing the function name and then the required parameters. Here is an example of a function that prints its inputs: | ||
<syntaxhighlight lang="python3"> | <syntaxhighlight lang="python3"> | ||
def printer(input1, input2="already there"): | def printer(input1, input2 = "already there"): | ||
print(input1) | print(input1) | ||
print(input2) | print(input2) | ||
| Line 388: | Line 313: | ||
[["Hello, World!" program]]: | [["Hello, World!" program]]: | ||
<syntaxhighlight lang="python"> | <syntaxhighlight lang="python"> | ||
print('Hello, | print('Hello, World!') | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Program to calculate the [[factorial]] of a | Program to calculate the [[factorial]] of a non-negative integer: | ||
<syntaxhighlight lang="python" line="1"> | <syntaxhighlight lang="python" line="1"> | ||
text = input('Type a number, and its factorial will be printed: ') | |||
n = int(text) | |||
if n < 0: | if n < 0: | ||
| Line 415: | Line 341: | ||
Some parts of the standard library are covered by specifications—for example, the [[Web Server Gateway Interface]] (WSGI) implementation <code>wsgiref</code> follows PEP 333<ref name="AutoNT-89"/>—but most parts are specified by their code, internal documentation, and [[test suite]]s. However, because most of the standard library is cross-platform Python code, only a few modules must be altered or rewritten for variant implementations. | Some parts of the standard library are covered by specifications—for example, the [[Web Server Gateway Interface]] (WSGI) implementation <code>wsgiref</code> follows PEP 333<ref name="AutoNT-89"/>—but most parts are specified by their code, internal documentation, and [[test suite]]s. However, because most of the standard library is cross-platform Python code, only a few modules must be altered or rewritten for variant implementations. | ||
{{As of|2025|03|13|post=,}} the [[Python Package Index]] (PyPI), the official repository for third-party Python software, contains over 614,339<ref name="PyPI">{{cite web |date=2025-03-13 |title=PyPI |url=https://pypi.org/ |url-status=live |archive-url=https://web.archive.org/web/20250222013445/https://pypi.org/ |archive-date=2025-02-22 |website=PyPI}}</ref> packages. | {{As of|2025|03|13|post=,}} the [[Python Package Index]] (PyPI), the official repository for third-party Python software, contains over 614,339<ref name="PyPI">{{cite web |date=2025-03-13 |title=PyPI |url=https://pypi.org/ |url-status=live |archive-url=https://web.archive.org/web/20250222013445/https://pypi.org/ |archive-date=2025-02-22 |website=PyPI}}</ref> packages. | ||
==Development environments== | ==Development environments== | ||
{{See also|Comparison of integrated development environments#Python}} | {{See also|Comparison of integrated development environments#Python}} | ||
Most Python implementations (including CPython) include a [[read–eval–print loop]] (REPL); this permits the environment to function as a [[command line interpreter]], with which users enter statements sequentially and receive results immediately. | Most{{which?|date=August 2025}} Python implementations (including CPython) include a [[read–eval–print loop]] (REPL); this permits the environment to function as a [[command line interpreter]], with which users enter statements sequentially and receive results immediately.<ref>{{cite web |title=Glossary: interactive |url=https://docs.python.org/3/glossary.html#term-interactive |website=Python documentation |access-date=31 August 2025 |language=en |version=v3.13.7}}</ref> | ||
Also, CPython is bundled with an [[integrated development environment|integrated development environment (IDE)]] called [[IDLE]],<ref name="idle">{{cite web |title=IDLE — Python editor and shell |url=https://docs.python.org/3/library/idle.html |website=Python documentation |version=v3.13.7 |access-date=31 August 2025 |language=en |quote=IDLE is Python's Integrated Development and Learning Environment.}}</ref> which is oriented toward beginners.{{cn|date=August 2025}} | |||
Other shells, including [[IDLE]] and [[IPython]], add additional capabilities such as improved auto-completion, session-state retention, and [[syntax highlighting]]. | Other shells, including [[IDLE]] and [[IPython]], add additional capabilities such as improved auto-completion, session-state retention, and [[syntax highlighting]].<ref name="idle" /><ref>{{cite web |title=IPython Documentation |url=https://ipython.readthedocs.io/en/stable/ |access-date=31 August 2025 |archive-url=https://web.archive.org/web/20250831204721/https://ipython.readthedocs.io/en/stable/ |archive-date=2025-08-31 |language=en |version=v9.5.0 |date=August 29, 2025 |url-status=live}}</ref> | ||
Standard desktop IDEs include PyCharm, | Standard desktop IDEs include [[PyCharm]], [[Spyder (software)|Spyder]], and [[Visual Studio Code]];{{cn|date=August 2025}} there are [[web browser]]-based IDEs, such as the following environments: | ||
* [[Project Jupyter|Jupyter Notebooks]], an open-source interactive computing platform;<ref>{{cite web |title=Project Jupyter |url=https://jupyter.org |website=Jupyter.org |access-date=2 April 2025 |archive-date=12 October 2023 |archive-url=https://web.archive.org/web/20231012055917/https://jupyter.org/ |url-status=live}}</ref> | |||
* [[Project Jupyter|Jupyter Notebooks]], an open-source interactive computing platform; | |||
* [[PythonAnywhere]], a browser-based IDE and hosting environment; and | * [[PythonAnywhere]], a browser-based IDE and hosting environment; and | ||
* Canopy | * Canopy, a commercial IDE from [[Enthought]] that emphasizes [[scientific computing]].<ref>{{cite web |last1=Harper |first1=Doug |title=Enthought Canopy |url=http://physics.wku.edu/phys316/software/canopy/ |website=WKU Physics 316 |publisher=[[Western Kentucky University]] |access-date=31 August 2025 |archive-url=https://web.archive.org/web/20240818041226/http://physics.wku.edu/phys316/software/canopy/ |archive-date=2024-08-18 |language=en |date=Spring 2024 |url-status=live}}</ref><ref>{{cite web|title=Enthought Canopy|url=https://www.enthought.com/products/canopy/|website=[[Enthought]]|access-date=20 August 2016|archive-date=15 July 2017|archive-url=https://web.archive.org/web/20170715151703/https://www.enthought.com/products/canopy/}}</ref> | ||
==Implementations== | ==Implementations== | ||
| Line 456: | Line 362: | ||
===Reference implementation=== | ===Reference implementation=== | ||
[[CPython]] is the [[reference implementation]] of Python. This implementation is written in C, meeting the [[C11 (C standard revision)|C11]] standard<ref>{{Cite web |title=PEP 7 – Style Guide for C Code {{!}} peps.python.org |url=https://peps.python.org/pep-0007/ |access-date=2022-04-28 |website=peps.python.org |archive-date=24 April 2022 |archive-url=https://web.archive.org/web/20220424202827/https://peps.python.org/pep-0007/ |url-status=live}}</ref> | [[CPython]] is the [[reference implementation]] of Python. This implementation is written in C, meeting the [[C11 (C standard revision)|C11]] standard<ref>{{Cite web |title=PEP 7 – Style Guide for C Code {{!}} peps.python.org |url=https://peps.python.org/pep-0007/ |access-date=2022-04-28 |website=peps.python.org |archive-date=24 April 2022 |archive-url=https://web.archive.org/web/20220424202827/https://peps.python.org/pep-0007/ |url-status=live}}</ref> since version 3.11. Older versions use the [[C89 (C version)|C89]] standard with several select [[C99]] features, but third-party extensions are not limited to older C versions—e.g., they can be implemented using C11 or C++.<ref>{{Cite web|title=4. Building C and C++ Extensions – Python 3.9.2 documentation|url=https://docs.python.org/3/extending/building.html|access-date=2021-03-01|website=docs.python.org|archive-date=3 March 2021|archive-url=https://web.archive.org/web/20210303002519/https://docs.python.org/3/extending/building.html|url-status=live}}</ref><ref name="AutoNT-66"/> CPython [[compiler|compiles]] Python programs into an intermediate [[bytecode]],<ref name="AutoNT-67"/> which is then executed by a [[virtual machine]].<ref name="AutoNT-68"/> CPython is distributed with a large standard library written in a combination of C and native Python. | ||
CPython is available for many platforms, including Windows and most modern [[Unix-like]] systems, including macOS (and [[Apple M1]] Macs, since Python 3.9.1, using an experimental installer). <!-- "Windows Vista support dropped in Python 3.7" -->Starting with Python 3.9, the Python installer intentionally fails to install on [[Windows 7]] and 8<!-- but not 8.1? -->;<ref>{{Cite web |title=Changelog – Python 3.9.0 documentation |url=https://docs.python.org/release/3.9.0/whatsnew/changelog.html#changelog |url-status=live |archive-url=https://web.archive.org/web/20210207001142/https://docs.python.org/release/3.9.0/whatsnew/changelog.html#changelog |archive-date=7 February 2021 |access-date=2021-02-08 |website=docs.python.org}}</ref><ref>{{Cite web |title=Download Python |url=https://www.python.org/downloads/release/python-391 |url-status=live |archive-url=https://web.archive.org/web/20201208045225/https://www.python.org/downloads/release/python-391/ |archive-date=8 December 2020 |access-date=2020-12-13 |website=Python.org |language=en}}</ref> [[Windows XP]] was supported until Python 3.5<!--"Windows XP support dropped in Python 3.5"-->, with unofficial support for [[OpenVMS|VMS]].<!--"Put online a new version of Python 3.10.0a (IA64only)"--><ref>{{Cite web|title=history [vmspython]|url=https://www.vmspython.org/doku.php?id=history|access-date=2020-12-04|website=www.vmspython.org|archive-date=2 December 2020|archive-url=https://web.archive.org/web/20201202194743/https://www.vmspython.org/doku.php?id=history|url-status=live}}</ref> Platform portability was one of Python's earliest priorities.<ref name="AutoNT-69" /> During development of Python 1 and 2, even [[OS/2]] and [[Solaris (operating system)|Solaris]] were supported;<!-- Also python-3.2.2 at http://unixpackages.com/packages/package-list --><ref | CPython is available for many platforms, including Windows and most modern [[Unix-like]] systems, including macOS (and [[Apple M1]] Macs, since Python 3.9.1, using an experimental installer). <!-- "Windows Vista support dropped in Python 3.7" -->Starting with Python 3.9, the Python installer intentionally fails to install on [[Windows 7]] and 8<!-- but not 8.1? -->;<ref>{{Cite web |title=Changelog – Python 3.9.0 documentation |url=https://docs.python.org/release/3.9.0/whatsnew/changelog.html#changelog |url-status=live |archive-url=https://web.archive.org/web/20210207001142/https://docs.python.org/release/3.9.0/whatsnew/changelog.html#changelog |archive-date=7 February 2021 |access-date=2021-02-08 |website=docs.python.org}}</ref><ref>{{Cite web |title=Download Python |url=https://www.python.org/downloads/release/python-391 |url-status=live |archive-url=https://web.archive.org/web/20201208045225/https://www.python.org/downloads/release/python-391/ |archive-date=8 December 2020 |access-date=2020-12-13 |website=Python.org |language=en}}</ref> [[Windows XP]] was supported until Python 3.5<!--"Windows XP support dropped in Python 3.5"-->, with unofficial support for [[OpenVMS|VMS]].<!--"Put online a new version of Python 3.10.0a (IA64only)"--><ref>{{Cite web|title=history [vmspython]|url=https://www.vmspython.org/doku.php?id=history|access-date=2020-12-04|website=www.vmspython.org|archive-date=2 December 2020|archive-url=https://web.archive.org/web/20201202194743/https://www.vmspython.org/doku.php?id=history|url-status=live}}</ref> Platform portability was one of Python's earliest priorities.<ref name="AutoNT-69" /> During development of Python 1 and 2, even [[OS/2]] and [[Solaris (operating system)|Solaris]] were supported;<!-- Also python-3.2.2 at http://unixpackages.com/packages/package-list --><ref name="DownloadOther"/><!-- older reference have access-date=2020-12-04 archive-date=27 November 2020 --> since that time, support has been dropped for many platforms.<!-- | ||
Starting with CPython 3.7.0, *nix platforms are expected to provide at least one of C.UTF-8 (full locale), C.utf8 (full locale) or UTF-8 (LC_CTYPE-only locale) as an alternative to the legacy C locale. | Starting with CPython 3.7.0, *nix platforms are expected to provide at least one of C.UTF-8 (full locale), C.utf8 (full locale) or UTF-8 (LC_CTYPE-only locale) as an alternative to the legacy C locale. | ||
| Line 464: | Line 370: | ||
All current Python versions (since 3.7) support only operating systems that feature multithreading<!-- (then in 3.7 removing support for [[IRIX]]; and before many other operating systems such as [[OS/2]] and [[VMS]]) -->, by now supporting not nearly as many operating systems (dropping many outdated) than in the past. | All current Python versions (since 3.7) support only operating systems that feature multithreading<!-- (then in 3.7 removing support for [[IRIX]]; and before many other operating systems such as [[OS/2]] and [[VMS]]) -->, by now supporting not nearly as many operating systems (dropping many outdated) than in the past. | ||
===Limitations of the reference implementation=== | |||
* The energy usage of Python with CPython for typically written code is much worse than C by a factor of 75.88.<ref name=":1">{{Cite book |last1=Pereira |first1=Rui |last2=Couto |first2=Marco |last3=Ribeiro |first3=Francisco |last4=Rua |first4=Rui |last5=Cunha |first5=Jácome |last6=Fernandes |first6=João Paulo |last7=Saraiva |first7=João |chapter=Energy efficiency across programming languages: How do energy, time, and memory relate? |date=2017-10-23 |title=Proceedings of the 10th ACM SIGPLAN International Conference on Software Language Engineering |chapter-url=https://doi.org/10.1145/3136014.3136031 |series=SLE 2017 |location=New York, NY, USA |publisher=Association for Computing Machinery |pages=256–267 |doi=10.1145/3136014.3136031 |isbn=978-1-4503-5525-4 |url=http://repositorio.inesctec.pt/handle/123456789/5492 }}</ref> | |||
* The throughput of Python with CPython for typically written code is worse than C by a factor of 71.9.<ref name=":1" /> | |||
* The average memory usage of CPython for typically written code is worse than C by a factor of 2.4.<ref name=":1" /> | |||
===Other implementations=== | ===Other implementations=== | ||
All alternative implementations have at least slightly different | All alternative implementations have at least slightly different semantics. For example, an alternative may include unordered dictionaries<!-- like with Codon; also PyPy? Cython? -->, in contrast to other current Python versions. As another example in the larger Python ecosystem, PyPy does not support the full C Python API. | ||
* [[PyPy]] is a | Creating an executable with Python often is done by bundling an entire Python interpreter into the executable, which causes binary sizes to be massive for small programs,<ref>{{cite web|url=https://pyinstaller.org/en/stable/operating-mode.html|title=What PyInstaller Does and How It Does It}}</ref> yet there exist implementations that are capable of truly compiling Python. Alternative implementations include the following: | ||
* Codon is an | |||
* [[PyPy]] is a faster, compliant interpreter of Python 2.7 and <!-- 3.8 (both are outdated CPython versions) --> 3.10.<ref name="AutoNT-70"/><ref>{{Cite web|last=Team|first=The PyPy|date=2019-12-28|title=Download and Install|url=https://www.pypy.org/download.html|access-date=2022-01-08|website=PyPy|language=en|archive-date=8 January 2022|archive-url=https://web.archive.org/web/20220108212951/https://www.pypy.org/download.html|url-status=live}}</ref> PyPy's [[just-in-time compiler]] often improves speed significantly relative to CPython, but PyPy does not support some libraries written in C.<ref name="AutoNT-71"/> PyPy offers support for the [[RISC-V]] instruction-set architecture. | |||
* Codon is an implementation with an [[ahead-of-time compilation|ahead-of-time (AOT) compiler]], which compiles a statically-typed Python-like language whose "syntax and semantics are nearly identical to Python's, there are some notable differences"<ref>{{Cite web |title=Codon: Differences with Python |url=https://docs.exaloop.io/codon/general/differences |url-status=live |archive-url=https://web.archive.org/web/20230525002540/https://docs.exaloop.io/codon/general/differences |archive-date=2023-05-25 |access-date=2023-08-28}}</ref> For example, Codon uses 64-bit machine integers for speed, not arbitrarily as with Python; Codon developers claim that speedups over CPython are usually on the order of ten to a hundred times. Codon compiles to machine code (via [[LLVM]]) and supports native multithreading.<ref>{{Cite web |last=Lawson |first=Loraine |date=2023-03-14 |title=MIT-Created Compiler Speeds up Python Code |url=https://thenewstack.io/mit-created-compiler-speeds-up-python-code/ |url-status=live |archive-url=https://web.archive.org/web/20230406054200/https://thenewstack.io/mit-created-compiler-speeds-up-python-code/ |archive-date=2023-04-06 |access-date=2023-08-28 |website=The New Stack |language=en-US}}</ref> <!-- It's compile has a restrictive BSL licence, but it doesn't affect generated code: --> Codon can also compile to Python extension modules that can be imported and used from Python. | |||
* [[MicroPython]] and [[CircuitPython]] are Python 3 variants that are optimized for [[microcontroller]]s, including the [[Lego Mindstorms EV3]].<ref>{{Cite web|url=https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3|title=Python-for-EV3|website=LEGO Education|language=en|access-date=17 April 2019|archive-date=7 June 2020|archive-url=https://web.archive.org/web/20200607234814/https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3|url-status=live}}</ref> | * [[MicroPython]] and [[CircuitPython]] are Python 3 variants that are optimized for [[microcontroller]]s, including the [[Lego Mindstorms EV3]].<ref>{{Cite web|url=https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3|title=Python-for-EV3|website=LEGO Education|language=en|access-date=17 April 2019|archive-date=7 June 2020|archive-url=https://web.archive.org/web/20200607234814/https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3|url-status=live}}</ref> | ||
* Pyston is a variant of the Python runtime that uses just-in-time compilation to speed up execution of Python programs.<ref>{{cite news|url=https://www.infoworld.com/article/3587591/pyston-returns-from-the-dead-to-speed-python.html|title=Pyston returns from the dead to speed Python|last=Yegulalp|first=Serdar|date=29 October 2020|website=[[InfoWorld]]|access-date=26 January 2021|archive-date=27 January 2021|archive-url=https://web.archive.org/web/20210127113233/https://www.infoworld.com/article/3587591/pyston-returns-from-the-dead-to-speed-python.html|url-status=live}}</ref> | * Pyston is a variant of the Python runtime that uses just-in-time compilation to speed up execution of Python programs.<ref>{{cite news|url=https://www.infoworld.com/article/3587591/pyston-returns-from-the-dead-to-speed-python.html|title=Pyston returns from the dead to speed Python|last=Yegulalp|first=Serdar|date=29 October 2020|website=[[InfoWorld]]|access-date=26 January 2021|archive-date=27 January 2021|archive-url=https://web.archive.org/web/20210127113233/https://www.infoworld.com/article/3587591/pyston-returns-from-the-dead-to-speed-python.html|url-status=live}}</ref> | ||
| Line 483: | Line 396: | ||
* [[PyS60]] was a Python 2 interpreter for [[Series 60]] mobile phones, which was released by [[Nokia]] in 2005. The interpreter implemented many modules from Python's standard library, as well as additional modules for integration with the [[Symbian]] operating system. The Nokia [[N900]] also supports Python through the [[GTK]] widget library, allowing programs to be written and run on the target device.<ref>{{cite web|title=Python on the Nokia N900|url=http://www.stochasticgeometry.ie/2010/04/29/python-on-the-nokia-n900/|website=Stochastic Geometry|date=29 April 2010|access-date=9 July 2015|archive-date=20 June 2019|archive-url=https://web.archive.org/web/20190620000053/http://www.stochasticgeometry.ie/2010/04/29/python-on-the-nokia-n900/|url-status=live}}</ref> | * [[PyS60]] was a Python 2 interpreter for [[Series 60]] mobile phones, which was released by [[Nokia]] in 2005. The interpreter implemented many modules from Python's standard library, as well as additional modules for integration with the [[Symbian]] operating system. The Nokia [[N900]] also supports Python through the [[GTK]] widget library, allowing programs to be written and run on the target device.<ref>{{cite web|title=Python on the Nokia N900|url=http://www.stochasticgeometry.ie/2010/04/29/python-on-the-nokia-n900/|website=Stochastic Geometry|date=29 April 2010|access-date=9 July 2015|archive-date=20 June 2019|archive-url=https://web.archive.org/web/20190620000053/http://www.stochasticgeometry.ie/2010/04/29/python-on-the-nokia-n900/|url-status=live}}</ref> | ||
=== | ===Transpilers to other languages=== | ||
There are several compilers/[[transpiler]]s to high-level object languages; the source language is unrestricted Python, a subset of Python, or a language similar to Python: | There are several compilers/[[transpiler]]s to high-level object languages; the source language is unrestricted Python, a subset of Python, or a language similar to Python: | ||
* Brython | * Brython<ref>{{Cite web|title=Brython|url=https://brython.info/|access-date=2021-01-21|website=brython.info|archive-date=3 August 2018|archive-url=https://web.archive.org/web/20180803065954/http://brython.info/|url-status=live}}</ref> and Transcrypt<ref>{{cite web|title=Transcrypt – Python in the browser|url=https://www.transcrypt.org|access-date=22 December 2020|website=transcrypt.org|language=en|archive-date=19 August 2018|archive-url=https://web.archive.org/web/20180819133303/http://www.transcrypt.org/|url-status=live}}</ref><ref>{{Cite web|url=https://www.infoq.com/articles/transcrypt-python-javascript-compiler/|title=Transcrypt: Anatomy of a Python to JavaScript Compiler|website=InfoQ|access-date=20 January 2021|archive-date=5 December 2020|archive-url=https://web.archive.org/web/20201205193339/https://www.infoq.com/articles/transcrypt-python-javascript-compiler/|url-status=live}}</ref> compile Python to [[JavaScript]]. | ||
* [[Cython]] compiles a superset of Python<!-- actually 2.7 by default, but Python 3 by override --> to C. The resulting code can be used with Python via direct C-level API calls into the Python interpreter. | * [[Cython]] compiles a superset of Python<!-- actually 2.7 by default, but Python 3 by override --> to C. The resulting code can be used with Python via direct C-level API calls into the Python interpreter. | ||
* PyJL compiles/transpiles a subset of Python to "human-readable, maintainable, and high-performance Julia source code".<ref name=PyJL>{{Cite web|title=Transpiling Python to Julia using PyJL|url=https://web.ist.utl.pt/antonio.menezes.leitao/ADA/documents/publications_docs/2022_TranspilingPythonToJuliaUsingPyJL.pdf|quote=After manually modifying one line of code by specifying the necessary type information, we obtained a speedup of 52.6×, making the translated Julia code 19.5× faster than the original Python code.|access-date=20 September 2023|archive-date=19 November 2023|archive-url=https://web.archive.org/web/20231119071525/https://web.ist.utl.pt/antonio.menezes.leitao/ADA/documents/publications_docs/2022_TranspilingPythonToJuliaUsingPyJL.pdf|url-status=live}}</ref> Despite the developers' performance claims, this is not possible for ''arbitrary'' Python code; that is, compiling to a faster language or machine code is known to be impossible in the general case. The semantics of Python might potentially be changed, but in many cases speedup is possible with few or no changes in the Python code. The faster Julia source code can then be used from Python or compiled to machine code. | * PyJL compiles/transpiles a subset of Python to "human-readable, maintainable, and high-performance Julia source code".<ref name=PyJL>{{Cite web|title=Transpiling Python to Julia using PyJL|url=https://web.ist.utl.pt/antonio.menezes.leitao/ADA/documents/publications_docs/2022_TranspilingPythonToJuliaUsingPyJL.pdf|quote=After manually modifying one line of code by specifying the necessary type information, we obtained a speedup of 52.6×, making the translated Julia code 19.5× faster than the original Python code.|access-date=20 September 2023|archive-date=19 November 2023|archive-url=https://web.archive.org/web/20231119071525/https://web.ist.utl.pt/antonio.menezes.leitao/ADA/documents/publications_docs/2022_TranspilingPythonToJuliaUsingPyJL.pdf|url-status=live}}</ref> Despite the developers' performance claims, this is not possible for ''arbitrary'' Python code; that is, compiling to a faster language or machine code is known to be impossible in the general case. The semantics of Python might potentially be changed, but in many cases speedup is possible with few or no changes in the Python code. The faster Julia source code can then be used from Python or compiled to machine code. | ||
* [[Nuitka]] compiles Python into C<!-- "is the optimizing Python compiler written in Python that creates executables that run without a separate installer"-->.<ref>{{cite web|title=Nuitka Home {{!}} Nuitka Home|url=http://nuitka.net/|access-date=18 August 2017|website=nuitka.net|language=en|archive-date=30 May 2020|archive-url=https://web.archive.org/web/20200530211233/https://nuitka.net/|url-status=live}}</ref> This compiler works with Python 3.4 to 3. | * [[Nuitka]] compiles Python into C<!-- "is the optimizing Python compiler written in Python that creates executables that run without a separate installer"-->.<ref>{{cite web|title=Nuitka Home {{!}} Nuitka Home|url=http://nuitka.net/|access-date=18 August 2017|website=nuitka.net|language=en|archive-date=30 May 2020|archive-url=https://web.archive.org/web/20200530211233/https://nuitka.net/|url-status=live}}</ref> This compiler works with Python 3.4 to 3.13 (and 2.6 and 2.7) for Python's main supported platforms (and Windows 7 or even Windows XP) and for Android. The compiler developers claim full support for Python 3.10, <!-- "also finishes full compatibility with the match statements of 3.10" "From here on, we need to re-visit compatibility. A few more obscured 3.10 features are missing, the 3.11 compatibility is not yet complete" -->partial support for Python 3.11 and 3.12, <!-- "This release bumps the long-awaited 3.12 support to a complete level. Now, Nuitka behaves identically to CPython 3.12 for the most part. .. After being late with 3.12 support, we will now be early with 3.13 support if all goes well." --> and experimental support for Python 3.13. Nuitka supports macOS including Apple Silicon-based versions. <!-- "While arm64 (M1) only builds and x86_64 (Intel) only builds work, the value universal which of course implies twice the size, and as such has other disadvantages, is not yet supported. --> The compiler is free of cost, though it has commercial add-ons (e.g., for hiding source code).<!-- "Container Builds (public + commercial)" --> | ||
* [[Numba]] is a JIT compiler that is used from Python; the compiler translates a subset of Python and NumPy code into fast machine code. This tool is enabled by adding a decorator to the relevant Python code. | * [[Numba]] is a JIT compiler that is used from Python; the compiler translates a subset of Python and NumPy code into fast machine code. This tool is enabled by adding a decorator to the relevant Python code. | ||
* Pythran compiles a subset of Python 3 to C++ ([[C++11]]).<ref name="Guelton Brunet Amini Merlini 2015 p=014001">{{cite journal |last1=Guelton |first1=Serge |last2=Brunet |first2=Pierrick |last3=Amini |first3=Mehdi |last4=Merlini |first4=Adrien |last5=Corbillon |first5=Xavier |last6=Raynaud |first6=Alan |title=Pythran: enabling static optimization of scientific Python programs |journal=Computational Science & Discovery |publisher=IOP Publishing |volume=8 |issue=1 |date=16 March 2015 |issn=1749-4699 |doi=10.1088/1749-4680/8/1/014001|doi-access=free | | * Pythran compiles a subset of Python 3 to C++ ([[C++11]]).<ref name="Guelton Brunet Amini Merlini 2015 p=014001">{{cite journal |last1=Guelton |first1=Serge |last2=Brunet |first2=Pierrick |last3=Amini |first3=Mehdi |last4=Merlini |first4=Adrien |last5=Corbillon |first5=Xavier |last6=Raynaud |first6=Alan |title=Pythran: enabling static optimization of scientific Python programs |journal=Computational Science & Discovery |publisher=IOP Publishing |volume=8 |issue=1 |date=16 March 2015 |issn=1749-4699 |doi=10.1088/1749-4680/8/1/014001|doi-access=free |article-number=014001 |bibcode=2015CS&D....8a4001G}}</ref> | ||
* [[RPython]] can be compiled to C, and it is used to build the PyPy interpreter for Python. | * [[RPython]] can be compiled to C, and it is used to build the PyPy interpreter for Python. | ||
* The Python → 11l → C++ transpiler<ref>{{Cite web |url=https://11l-lang.org/transpiler |title=The Python → 11l → C++ transpiler |access-date=17 July 2022 |archive-date=24 September 2022 |archive-url=https://web.archive.org/web/20220924233728/https://11l-lang.org/transpiler/ |url-status=live}}</ref> compiles a subset of Python 3 to C++ ([[C++17]]). | * The Python → 11l → C++ transpiler<ref>{{Cite web |url=https://11l-lang.org/transpiler |title=The Python → 11l → C++ transpiler |access-date=17 July 2022 |archive-date=24 September 2022 |archive-url=https://web.archive.org/web/20220924233728/https://11l-lang.org/transpiler/ |url-status=live}}</ref> compiles a subset of Python 3 to C++ ([[C++17]]). | ||
| Line 504: | Line 417: | ||
===Performance=== | ===Performance=== | ||
A | A performance comparison among various Python implementations, using a non-numerical (combinatorial) workload, was presented at EuroSciPy '13.<ref>{{cite conference |title=Performance of Python runtimes on a non-numeric scientific code |last=Murri |first=Riccardo |conference=European Conference on Python in Science (EuroSciPy) |year=2013 |arxiv=1404.6388|bibcode=2014arXiv1404.6388M}}</ref> In addition, Python's performance relative to other programming languages is benchmarked by [[The Computer Language Benchmarks Game]].<ref>{{cite web|title=The Computer Language Benchmarks Game|url=https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/python.html|access-date=30 April 2020|archive-date=14 June 2020|archive-url=https://web.archive.org/web/20200614210246/https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/python.html|url-status=live}}</ref> | ||
There are several approaches to optimizing Python performance, | There are several approaches to optimizing Python performance, despite the inherent slowness of an [[interpreted language]]. These approaches include the following strategies or tools: | ||
* [[Just-in-time compilation]]: Dynamically compiling Python | * [[Just-in-time compilation]]: Dynamically compiling parts of a Python program during the execution of the program. This technique is used in libraries such as [[Numba]] and [[PyPy]]. | ||
* [[Compiler|Static compilation]]: Python code | * [[Compiler|Static compilation]]: Sometimes, Python code can be compiled into machine code sometime before execution. An example of this approach is [[Cython]], which compiles Python into C. | ||
* Concurrency and parallelism: Multiple tasks can be run simultaneously. Python contains modules such as `multiprocessing` to support this form of parallelism. Moreover, this approach helps to overcome limitations of the [[Global interpreter lock|Global Interpreter Lock]] (GIL) in CPU tasks. | * [[Concurrent computing|Concurrency]] and [[Parallel computing|parallelism]]: Multiple tasks can be run simultaneously. Python contains modules such as `multiprocessing` to support this form of parallelism. Moreover, this approach helps to overcome limitations of the [[Global interpreter lock|Global Interpreter Lock]] (GIL) in CPU tasks. | ||
* Efficient data structures: Performance can also be improved by using data types such as <code>Set</code> for membership tests, or <code>deque</code> from <code>collections</code> for [[Queueing theory|queue]] operations. | * Efficient [[data structures]]: Performance can also be improved by using data types such as <code>Set</code> for membership tests, or <code>deque</code> from <code>collections</code> for [[Queueing theory|queue]] operations. | ||
* Performance gains can be observed by utilizing libraries such as [[NumPy]]. Most high performance Python libraries use [[C (programming language)|C]] or [[Fortran]] under the hood instead of the Python interpreter.<ref>{{Cite web |last=Python |first=Real |title=Look Ma, No for Loops: Array Programming With NumPy – Real Python |url=https://realpython.com/numpy-array-programming/ |access-date=2025-10-15 |website=realpython.com |language=en}}</ref> | |||
==Language Development== | ==Language Development== | ||
Python's development is conducted | Python's development is conducted mostly through the ''Python Enhancement Proposal'' (PEP) process; this process is the primary mechanism for proposing major new features, collecting community input on issues, and documenting Python design decisions.<ref name="PepCite000"/> Python coding style is covered in PEP 8.<ref name="pep8"/> Outstanding PEPs are reviewed and commented on by the Python community and the steering council.<ref name="PepCite000"/> | ||
Enhancement of the language corresponds with development of the CPython reference implementation. The mailing list python-dev is the primary forum for the language's development. Specific issues were originally discussed in the [[Roundup (issue tracker)|Roundup]] [[bug tracker]] hosted by the foundation.<ref name="AutoNT-21"/> In 2022, all issues and discussions were migrated to [[GitHub]].<ref>{{cite web |url=https://lwn.net/Articles/885854/ |title=Moving Python's bugs to GitHub [LWN.net] |access-date=2 October 2022 |archive-date=2 October 2022 |archive-url=https://web.archive.org/web/20221002183818/https://lwn.net/Articles/885854/ |url-status=live}}</ref> Development originally took place on a [[Self-hosting (web services)|self-hosted]] source-code repository running [[Mercurial]], until Python moved to [[GitHub]] in January 2017.<ref name=py_dev_guide>{{Cite web|url=https://devguide.python.org/|title=Python Developer's Guide – Python Developer's Guide|website=devguide.python.org|access-date=17 December 2019|archive-date=9 November 2020|archive-url=https://web.archive.org/web/20201109032501/https://devguide.python.org/|url-status=live}}</ref> | Enhancement of the language corresponds with development of the CPython reference implementation. The mailing list python-dev is the primary forum for the language's development. Specific issues were originally discussed in the [[Roundup (issue tracker)|Roundup]] [[bug tracker]] hosted by the foundation.<ref name="AutoNT-21"/> In 2022, all issues and discussions were migrated to [[GitHub]].<ref>{{cite web |last1=Edge |first1=Jake |url=https://lwn.net/Articles/885854/ |title=Moving Python's bugs to GitHub [LWN.net] |date=23 February 2022 |access-date=2 October 2022 |archive-date=2 October 2022 |archive-url=https://web.archive.org/web/20221002183818/https://lwn.net/Articles/885854/ |url-status=live}}</ref> Development originally took place on a [[Self-hosting (web services)|self-hosted]] source-code repository running [[Mercurial]], until Python moved to [[GitHub]] in January 2017.<ref name=py_dev_guide>{{Cite web|url=https://devguide.python.org/|title=Python Developer's Guide – Python Developer's Guide|website=devguide.python.org|access-date=17 December 2019|archive-date=9 November 2020|archive-url=https://web.archive.org/web/20201109032501/https://devguide.python.org/|url-status=live}}</ref> | ||
CPython's public releases have three types, distinguished by which part of the version number is incremented: | CPython's public releases have three types, distinguished by which part of the version number is incremented: | ||
* ''Backward-incompatible versions'', where code is expected to break and must be manually [[ported]]. The first part of the version number is incremented. These releases happen infrequently—version 3.0 was released 8 years after 2.0. According to Guido van Rossum, a version 4.0 will probably never exist.<ref>{{Cite web |last=Hughes |first=Owen |date=2021-05-24 |title=Programming languages: Why Python 4.0 might never arrive, according to its creator |url=https://www.techrepublic.com/article/programming-languages-why-python-4-0-will-probably-never-arrive-according-to-its-creator/ |access-date=2022-05-16 |website=TechRepublic |language=en-US |archive-date=14 July 2022 |archive-url=https://web.archive.org/web/20220714201302/https://www.techrepublic.com/article/programming-languages-why-python-4-0-will-probably-never-arrive-according-to-its-creator/ |url-status=live}}</ref> | * ''Backward-incompatible versions'', where code is expected to break and must be manually [[ported]]. The first part of the version number is incremented. These releases happen infrequently—version 3.0 was released 8 years after 2.0. According to Guido van Rossum, a version 4.0 will probably never exist.<ref>{{Cite web |last=Hughes |first=Owen |date=2021-05-24 |title=Programming languages: Why Python 4.0 might never arrive, according to its creator |url=https://www.techrepublic.com/article/programming-languages-why-python-4-0-will-probably-never-arrive-according-to-its-creator/ |access-date=2022-05-16 |website=TechRepublic |language=en-US |archive-date=14 July 2022 |archive-url=https://web.archive.org/web/20220714201302/https://www.techrepublic.com/article/programming-languages-why-python-4-0-will-probably-never-arrive-according-to-its-creator/ |url-status=live}}</ref> | ||
* ''Major or "feature" releases'' are largely compatible with the previous version but introduce new features. The second part of the version number is incremented. Starting with Python 3.9, these releases are expected to occur annually.<ref>{{Cite web|url=https://www.python.org/dev/peps/pep-0602/|title=PEP 602 – Annual Release Cycle for Python|website=Python.org|language=en|access-date=6 November 2019|archive-date=14 June 2020|archive-url=https://web.archive.org/web/20200614202755/https://www.python.org/dev/peps/pep-0602/|url-status=live}}</ref><ref>{{Cite web|url=https://lwn.net/Articles/802777/|title=Changing the Python release cadence [LWN.net]|website=lwn.net|access-date=6 November 2019|archive-date=6 November 2019|archive-url=https://web.archive.org/web/20191106170153/https://lwn.net/Articles/802777/|url-status=live}}</ref> Each major version is supported by bug fixes for several years after its release.<ref name="release-schedule"/> | * ''Major or "feature" releases'' are largely compatible with the previous version but introduce new features. The second part of the version number is incremented. Starting with Python 3.9, these releases are expected to occur annually.<ref>{{Cite web|url=https://www.python.org/dev/peps/pep-0602/|title=PEP 602 – Annual Release Cycle for Python|website=Python.org|language=en|access-date=6 November 2019|archive-date=14 June 2020|archive-url=https://web.archive.org/web/20200614202755/https://www.python.org/dev/peps/pep-0602/|url-status=live}}</ref><ref>{{Cite web|last1=Edge |first1=Jake |url=https://lwn.net/Articles/802777/|title=Changing the Python release cadence [LWN.net]|website=lwn.net|date=23 October 2019 |access-date=6 November 2019|archive-date=6 November 2019|archive-url=https://web.archive.org/web/20191106170153/https://lwn.net/Articles/802777/|url-status=live}}</ref> Each major version is supported by bug fixes for several years after its release.<ref name="release-schedule"/> | ||
* ''Bug fix releases'',<ref name="AutoNT-22"/> which introduce no new features, occur approximately every three months; these releases are made when a sufficient number of bugs have been fixed [[Upstream (software development)|upstream]] since the last release. Security vulnerabilities are also patched in these releases. The third and final part of the version number is incremented.<ref name="AutoNT-22"/> | * ''Bug fix releases'',<ref name="AutoNT-22"/> which introduce no new features, occur approximately every three months; these releases are made when a sufficient number of bugs have been fixed [[Upstream (software development)|upstream]] since the last release. Security vulnerabilities are also patched in these releases. The third and final part of the version number is incremented.<ref name="AutoNT-22"/> | ||
Many [[beta release|alpha, beta, and release-candidates]] are also released as previews and for testing before final releases. Although there is a rough schedule for releases, they are often delayed if the code is not ready yet. Python's development team monitors the state of the code by running a large [[unit test]] suite during development.<ref name="AutoNT-23"/> | Many [[beta release|alpha, beta, and release-candidates]] are also released as previews and for testing before final releases. Although there is a rough schedule for releases, they are often delayed if the code is not ready yet. Python's development team monitors the state of the code by running a large [[unit test]] suite during development.<ref name="AutoNT-23"/> | ||
The major [[academic conference]] on Python is [[PyCon]]. | The major [[academic conference]] on Python is [[PyCon]]. Also, there are special Python mentoring programs, such as [[PyLadies]]. | ||
==Naming== | ==Naming== | ||
Python's name is inspired by the British comedy group [[Monty Python]], whom Python creator Guido van Rossum enjoyed while developing the language. Monty Python references appear frequently in Python code and culture;<ref name="tutorial-chapter1"/> for example, the [[metasyntactic variable]]s often used in Python literature are [[Spam (Monty Python)|''spam'' and ''eggs'']], rather than the traditional [[foobar|''foo'' and ''bar'']].<ref name="tutorial-chapter1"/><ref name="AutoNT-26"/> | Python's name is inspired by the British comedy group [[Monty Python]], whom Python creator Guido van Rossum enjoyed while developing the language. Monty Python references appear frequently in Python code and culture;<ref name="tutorial-chapter1"/> for example, the [[metasyntactic variable]]s often used in Python literature are [[Spam (Monty Python)|''spam'' and ''eggs'']], rather than the traditional [[foobar|''foo'' and ''bar'']].<ref name="tutorial-chapter1"/><ref name="AutoNT-26"/> Also, the official Python documentation contains various references to Monty Python routines.{{sfn|Lutz|2013|p=17}}<ref>{{cite book |last1=Fehily |first1=Chris |title=Python |year=2002 |publisher=Peachpit Press |isbn=978-0-201-74884-0 |page=xv |url=https://books.google.com/books?id=carqdIdfVlYC&pg=PR15 |language=en |access-date=9 May 2017 |archive-date=17 July 2017 |archive-url=https://web.archive.org/web/20170717044040/https://books.google.com/books?id=carqdIdfVlYC&pg=PR15 |url-status=live}}</ref> Python users are sometimes referred to as "Pythonistas".<ref name="introducing_python">{{Cite book |publisher=Sebastopol, CA : O'Reilly Media |isbn=978-1-4493-5936-2 |last=Lubanovic |first=Bill |title=Introducing Python |access-date=2023-07-31 |date=2014 |url=http://archive.org/details/introducingpytho0000luba |page=305}}</ref> | ||
==Languages influenced by Python== | ==Languages influenced by Python== | ||
* [[Cobra (programming language)|Cobra]] has an ''Acknowledgements'' document that lists Python first among influencing languages.<ref>{{cite web |url=http://cobra-language.com/docs/acknowledgements/ |title=Acknowledgements |last=Esterbrook |first=Charles |work=cobra-language.com |publisher=Cobra Language |access-date=7 April 2010 |archive-date=8 February 2008 |archive-url=https://web.archive.org/web/20080208141002/http://cobra-language.com/docs/acknowledgements/ |url-status=dead}}</ref> | |||
* [[ECMAScript]] and [[JavaScript]] borrowed iterators and [[generator (computer science)|generators]] from Python.<ref>{{cite web |url=http://wiki.ecmascript.org/doku.php?id=proposals:iterators_and_generators |archive-url=https://web.archive.org/web/20071020082650/http://wiki.ecmascript.org/doku.php?id=proposals:iterators_and_generators |url-status=dead |archive-date=20 October 2007 |title=Proposals: iterators and generators [ES4 Wiki] |publisher=wiki.ecmascript.org |access-date=24 November 2008}}</ref> | |||
* [[Cobra (programming language)|Cobra]] | * [[Go (programming language)|Go]] is designed for "speed of working in a dynamic language like Python".<ref>{{cite news |url=https://techcrunch.com/2009/11/10/google-go-language/ |title=Google's Go: A New Programming Language That's Python Meets C++ |last=Kincaid |first=Jason |date=10 November 2009 |work=TechCrunch |access-date=29 January 2010 |archive-date=18 January 2010 |archive-url=https://web.archive.org/web/20100118014358/http://www.techcrunch.com/2009/11/10/google-go-language/ |url-status=live}}</ref> | ||
* [[Julia (programming language)|Julia]] was designed to be "as usable for general programming as Python".<ref>{{cite web |title= Why We Created Julia |date= February 2012 |website= Julia website |url= https://julialang.org/blog/2012/02/why-we-created-julia |access-date= 5 June 2014 |quote= We want something as usable for general programming as Python [...] |archive-date= 2 May 2020 |archive-url= https://web.archive.org/web/20200502144010/https://julialang.org/blog/2012/02/why-we-created-julia/ |url-status= live}}</ref> | |||
* [[ECMAScript]] | * [[Mojo (programming language)|Mojo]] is almost<ref name="Mojo"/><ref>{{Cite web |title=Modular Docs – Why Mojo |url=https://docs.modular.com/mojo/why-mojo.html |access-date=2023-05-05 |website=docs.modular.com |language=en |quote=Mojo as a member of the Python family [..] Embracing Python massively simplifies our design efforts, because most of the syntax is already specified. [..] we decided that the right long-term goal for Mojo is to provide a superset of Python (i.e. be compatible with existing programs) and to embrace the CPython immediately for long-tail ecosystem enablement. To a Python programmer, we expect and hope that Mojo will be immediately familiar, while also providing new tools for developing systems-level code that enable you to do things that Python falls back to C and C++ for. |archive-date=5 May 2023 |archive-url=https://web.archive.org/web/20230505083518/https://docs.modular.com/mojo/why-mojo.html |url-status=live}}</ref> a superset of Python.<ref>{{Cite web |last=Spencer |first=Michael |title=What is Mojo Programming Language? |url=https://datasciencelearningcenter.substack.com/p/what-is-mojo-programming-language |access-date=2023-05-05 |website=datasciencelearningcenter.substack.com |date=4 May 2023 |language=en |archive-date=5 May 2023 |archive-url=https://web.archive.org/web/20230505090408/https://datasciencelearningcenter.substack.com/p/what-is-mojo-programming-language |url-status=live}}</ref> | ||
* [[GDScript]] is strongly influenced by Python. {{cn|date=November 2025}} | |||
* [[Go (programming language)|Go]] is designed for "speed of working in a dynamic language like Python" | * [[Apache Groovy| Groovy]], [[Boo (programming language)|Boo]], [[CoffeeScript]], [[F Sharp (programming language)|F#]], [[Nim (programming language)|Nim]], [[Ring (programming language)|Ring]],<ref name="The Ring programming language and other languages"></ref> [[Ruby (programming language)|Ruby]],<ref name="bini"></ref> [[Swift (programming language)|Swift]],<ref name="lattner2014"></ref> and [[V (programming language)|V]]<ref name="vpeople"></ref> have been influenced, as well. | ||
* [[Julia (programming language)|Julia]] was designed to be "as usable for general programming as Python".<ref | |||
* [[Mojo (programming language)|Mojo]] is | |||
* [[ | |||
* [[ | |||
==See also== | ==See also== | ||
{{Portal|Computer programming|Free and open-source software}} | {{Portal|Computer programming|Free and open-source software}} | ||
* [[Python | * [[List of computer books#Python|List of Python programming books]] | ||
* [[pip (package manager)]] | * [[pip (package manager)]] | ||
* [[ | * [[Pydoc]] | ||
* [[ | * [[NumPy]] | ||
* [[ | * [[SciPy]] | ||
* [[Jupyter]] | |||
* [[Pytorch]] | |||
* [[Cython]] | |||
* [[CPython]] | |||
* [[Mojo (programming language)|Mojo]] | |||
* [[Pygame]] | |||
* [[PyQt]] | |||
* [[PyGTK]] | |||
* [[PyPy]] | |||
* [[PyCon]] | |||
* [[Google Colab]]{{snd}} zero setup [[Online integrated development environment|online IDE]] that runs Python | |||
{{Clear}} | {{Clear}} | ||
| Line 624: | Line 482: | ||
<ref name="faq-created">{{cite web |url=https://docs.python.org/faq/general.html#why-was-python-created-in-the-first-place |title=Why was Python created in the first place? |work=General Python FAQ |publisher=Python Software Foundation |access-date=22 March 2007 |archive-date=24 October 2012 |archive-url=https://web.archive.org/web/20121024164224/http://docs.python.org/faq/general.html#why-was-python-created-in-the-first-place |url-status=live |quote=I had extensive experience with implementing an interpreted language in the ABC group at CWI, and from working with this group I had learned a lot about language design. This is the origin of many Python features, including the use of indentation for statement grouping and the inclusion of very high-level data types (although the details are all different in Python).}}</ref> | <ref name="faq-created">{{cite web |url=https://docs.python.org/faq/general.html#why-was-python-created-in-the-first-place |title=Why was Python created in the first place? |work=General Python FAQ |publisher=Python Software Foundation |access-date=22 March 2007 |archive-date=24 October 2012 |archive-url=https://web.archive.org/web/20121024164224/http://docs.python.org/faq/general.html#why-was-python-created-in-the-first-place |url-status=live |quote=I had extensive experience with implementing an interpreted language in the ABC group at CWI, and from working with this group I had learned a lot about language design. This is the origin of many Python features, including the use of indentation for statement grouping and the inclusion of very high-level data types (although the details are all different in Python).}}</ref> | ||
<ref name="98-interview">{{cite web |url=http://www.amk.ca/python/writing/gvr-interview |title=Interview with Guido van Rossum (July 1998) |last=Kuchling |first=Andrew M. |work=amk.ca |date=22 December 2006 |access-date=12 March 2012 | <ref name="98-interview">{{cite web |url=http://www.amk.ca/python/writing/gvr-interview |title=Interview with Guido van Rossum (July 1998) |last=Kuchling |first=Andrew M. |work=amk.ca |date=22 December 2006 |access-date=12 March 2012 |archive-url=https://web.archive.org/web/20070501105422/http://www.amk.ca/python/writing/gvr-interview |archive-date=1 May 2007 |quote=I'd spent a summer at DEC's Systems Research Center, which introduced me to Modula-2+; the Modula-3 final report was being written there at about the same time. What I learned there later showed up in Python's exception handling, modules, and the fact that methods explicitly contain 'self' in their parameter list. String slicing came from Algol-68 and Icon.}}</ref> | ||
<ref name="AutoNT-1">{{cite journal |last=van Rossum |first=Guido |year=1993 |title=An Introduction to Python for UNIX/C Programmers |journal=Proceedings of the NLUUG Najaarsconferentie (Dutch UNIX Users Group) |quote=even though the design of C is far from ideal, its influence on Python is considerable. |citeseerx=10.1.1.38.2023}}</ref> | <ref name="AutoNT-1">{{cite journal |last=van Rossum |first=Guido |year=1993 |title=An Introduction to Python for UNIX/C Programmers |journal=Proceedings of the NLUUG Najaarsconferentie (Dutch UNIX Users Group) |quote=even though the design of C is far from ideal, its influence on Python is considerable. |citeseerx=10.1.1.38.2023}}</ref> | ||
| Line 644: | Line 502: | ||
<ref name="bini">{{cite book |last=Bini |first=Ola |title=Practical JRuby on Rails Web 2.0 Projects: bringing Ruby on Rails to the Java platform |year=2007 |publisher=APress |location=Berkeley |isbn=978-1-59059-881-8 |page=[https://archive.org/details/practicaljrubyon0000bini/page/3 3] |url-access=registration |url=https://archive.org/details/practicaljrubyon0000bini/page/3}}</ref> | <ref name="bini">{{cite book |last=Bini |first=Ola |title=Practical JRuby on Rails Web 2.0 Projects: bringing Ruby on Rails to the Java platform |year=2007 |publisher=APress |location=Berkeley |isbn=978-1-59059-881-8 |page=[https://archive.org/details/practicaljrubyon0000bini/page/3 3] |url-access=registration |url=https://archive.org/details/practicaljrubyon0000bini/page/3}}</ref> | ||
<ref name="AutoNT-7">{{cite web |last=Kuhlman |first=Dave |url=https://www.davekuhlman.org/python_book_01.pdf|title=A Python Book: Beginning Python, Advanced Python, and Python Exercises |at=Section 1.1 | <ref name="AutoNT-7">{{cite web |last=Kuhlman |first=Dave |url=https://www.davekuhlman.org/python_book_01.pdf|title=A Python Book: Beginning Python, Advanced Python, and Python Exercises |at=Section 1.1|archive-url=https://web.archive.org/web/20120623165941/http://cutter.rexx.com/~dkuhlman/python_book_01.html |archive-date=23 June 2012}}</ref> | ||
<ref name="venners-interview-pt-1">{{cite web |url=http://www.artima.com/intv/pythonP.html |title=The Making of Python |last=Venners |first=Bill |date=13 January 2003 |work=Artima Developer |publisher=Artima |access-date=22 March 2007 |archive-date=1 September 2016 |archive-url=https://web.archive.org/web/20160901183332/http://www.artima.com/intv/pythonP.html |url-status=live}}</ref> | <ref name="venners-interview-pt-1">{{cite web |url=http://www.artima.com/intv/pythonP.html |title=The Making of Python |last=Venners |first=Bill |date=13 January 2003 |work=Artima Developer |publisher=Artima |access-date=22 March 2007 |archive-date=1 September 2016 |archive-url=https://web.archive.org/web/20160901183332/http://www.artima.com/intv/pythonP.html |url-status=live}}</ref> | ||
| Line 656: | Line 512: | ||
<ref name="newin-2.0">{{cite web |url=https://docs.python.org/whatsnew/2.0.html |title=What's New in Python 2.0 |last1=Kuchling |first1=A. M. |last2=Zadka |first2=Moshe |date=16 October 2000 |publisher=Python Software Foundation |access-date=11 February 2012 |archive-date=23 October 2012 |archive-url=https://web.archive.org/web/20121023112045/http://docs.python.org/whatsnew/2.0.html |url-status=live}}</ref> | <ref name="newin-2.0">{{cite web |url=https://docs.python.org/whatsnew/2.0.html |title=What's New in Python 2.0 |last1=Kuchling |first1=A. M. |last2=Zadka |first2=Moshe |date=16 October 2000 |publisher=Python Software Foundation |access-date=11 February 2012 |archive-date=23 October 2012 |archive-url=https://web.archive.org/web/20121023112045/http://docs.python.org/whatsnew/2.0.html |url-status=live}}</ref> | ||
<ref name="AutoNT-13">{{cite web |url=https://www.python.org/community/pycon/dc2004/papers/24/metaclasses-pycon.pdf |archive-url=https://web.archive.org/web/20090530030205/http://www.python.org/community/pycon/dc2004/papers/24/metaclasses-pycon.pdf |archive-date=30 May 2009 |title=Python Metaclasses: Who? Why? When? |last=The Cain Gang Ltd. |access-date=27 June 2009 | <ref name="AutoNT-13">{{cite web |url=https://www.python.org/community/pycon/dc2004/papers/24/metaclasses-pycon.pdf |archive-url=https://web.archive.org/web/20090530030205/http://www.python.org/community/pycon/dc2004/papers/24/metaclasses-pycon.pdf |archive-date=30 May 2009 |title=Python Metaclasses: Who? Why? When? |last=The Cain Gang Ltd. |access-date=27 June 2009 }}</ref> | ||
<ref name="AutoNT-14">{{cite web |url=https://docs.python.org/3.0/reference/datamodel.html#special-method-names |title=3.3. Special method names |work=The Python Language Reference |publisher=Python Software Foundation |access-date=27 June 2009 |archive-date=15 December 2018 |archive-url=https://web.archive.org/web/20181215123146/https://docs.python.org/3.0/reference/datamodel.html#special-method-names |url-status=live}}</ref> | <ref name="AutoNT-14">{{cite web |url=https://docs.python.org/3.0/reference/datamodel.html#special-method-names |title=3.3. Special method names |work=The Python Language Reference |publisher=Python Software Foundation |access-date=27 June 2009 |archive-date=15 December 2018 |archive-url=https://web.archive.org/web/20181215123146/https://docs.python.org/3.0/reference/datamodel.html#special-method-names |url-status=live}}</ref> | ||
| Line 672: | Line 528: | ||
<ref name="AutoNT-19">{{cite book |url=http://shop.oreilly.com/product/9780596007973.do |title=Python Cookbook, 2nd Edition |publisher=[[O'Reilly Media]] |last1=Martelli |first1=Alex |last2=Ravenscroft |first2=Anna |last3=Ascher |first3=David |year=2005 |page=230 |isbn=978-0-596-00797-3 |access-date=14 November 2015 |archive-date=23 February 2020 |archive-url=https://web.archive.org/web/20200223171254/http://shop.oreilly.com/product/9780596007973.do |url-status=live}}</ref> | <ref name="AutoNT-19">{{cite book |url=http://shop.oreilly.com/product/9780596007973.do |title=Python Cookbook, 2nd Edition |publisher=[[O'Reilly Media]] |last1=Martelli |first1=Alex |last2=Ravenscroft |first2=Anna |last3=Ascher |first3=David |year=2005 |page=230 |isbn=978-0-596-00797-3 |access-date=14 November 2015 |archive-date=23 February 2020 |archive-url=https://web.archive.org/web/20200223171254/http://shop.oreilly.com/product/9780596007973.do |url-status=live}}</ref> | ||
<ref name="AutoNT-20">{{cite web |title=Python Culture |website=ebeab |date=January 21, 2014 |url=http://ebeab.com/2014/01/21/python-culture/ |archive-url=https://web.archive.org/web/20140130021902/http://ebeab.com/2014/01/21/python-culture/ |archive-date=January 30, 2014 | <ref name="AutoNT-20">{{cite web |title=Python Culture |website=ebeab |date=January 21, 2014 |url=http://ebeab.com/2014/01/21/python-culture/ |archive-url=https://web.archive.org/web/20140130021902/http://ebeab.com/2014/01/21/python-culture/ |archive-date=January 30, 2014 }}</ref> | ||
<ref name="PepCite000">{{cite web |url=https://www.python.org/dev/peps/pep-0001/ |title=PEP 1 – PEP Purpose and Guidelines |last1=Warsaw |first1=Barry |last2=Hylton |first2=Jeremy |last3=Goodger |first3=David |date=13 June 2000 |work=Python Enhancement Proposals |publisher=Python Software Foundation |access-date=19 April 2011 |archive-date=6 June 2020 |archive-url=https://web.archive.org/web/20200606042011/https://www.python.org/dev/peps/pep-0001/ |url-status=live}}</ref> | <ref name="PepCite000">{{cite web |url=https://www.python.org/dev/peps/pep-0001/ |title=PEP 1 – PEP Purpose and Guidelines |last1=Warsaw |first1=Barry |last2=Hylton |first2=Jeremy |last3=Goodger |first3=David |date=13 June 2000 |work=Python Enhancement Proposals |publisher=Python Software Foundation |access-date=19 April 2011 |archive-date=6 June 2020 |archive-url=https://web.archive.org/web/20200606042011/https://www.python.org/dev/peps/pep-0001/ |url-status=live}}</ref> | ||
<ref name="AutoNT-21">{{cite web |url=https://www.python.org/dev/intro/ |title=Guido, Some Guys, and a Mailing List: How Python is Developed |last=Cannon |first=Brett |work=python.org |publisher=Python Software Foundation |access-date=27 June 2009 | <ref name="AutoNT-21">{{cite web |url=https://www.python.org/dev/intro/ |title=Guido, Some Guys, and a Mailing List: How Python is Developed |last=Cannon |first=Brett |work=python.org |publisher=Python Software Foundation |access-date=27 June 2009 |archive-url=https://web.archive.org/web/20090601134342/http://www.python.org/dev/intro/ |archive-date=1 June 2009}}</ref> | ||
<ref name="release-schedule">{{cite web |url=https://mail.python.org/pipermail/python-dev/2002-April/022739.html |title=[Python-Dev] Release Schedules (was Stability & change) |last=Norwitz |first=Neal |date=8 April 2002 |access-date=27 June 2009 |archive-date=15 December 2018 |archive-url=https://web.archive.org/web/20181215122750/https://mail.python.org/pipermail/python-dev/2002-April/022739.html |url-status=live}}</ref> | <ref name="release-schedule">{{cite web |url=https://mail.python.org/pipermail/python-dev/2002-April/022739.html |title=[Python-Dev] Release Schedules (was Stability & change) |last=Norwitz |first=Neal |date=8 April 2002 |access-date=27 June 2009 |archive-date=15 December 2018 |archive-url=https://web.archive.org/web/20181215122750/https://mail.python.org/pipermail/python-dev/2002-April/022739.html |url-status=live}}</ref> | ||
| Line 689: | Line 545: | ||
<ref name="AutoNT-26">{{cite web |url=https://stackoverflow.com/questions/5033906/in-python-should-i-use-else-after-a-return-in-an-if-block |title=In Python, should I use else after a return in an if block? |date=17 February 2011 |work=[[Stack Overflow]] |publisher=Stack Exchange |access-date=6 May 2011 |archive-date=20 June 2019 |archive-url=https://web.archive.org/web/20190620000050/https://stackoverflow.com/questions/5033906/in-python-should-i-use-else-after-a-return-in-an-if-block |url-status=live}}</ref> | <ref name="AutoNT-26">{{cite web |url=https://stackoverflow.com/questions/5033906/in-python-should-i-use-else-after-a-return-in-an-if-block |title=In Python, should I use else after a return in an if block? |date=17 February 2011 |work=[[Stack Overflow]] |publisher=Stack Exchange |access-date=6 May 2011 |archive-date=20 June 2019 |archive-url=https://web.archive.org/web/20190620000050/https://stackoverflow.com/questions/5033906/in-python-should-i-use-else-after-a-return-in-an-if-block |url-status=live}}</ref> | ||
<ref name="AutoNT-52">{{cite web |title=Is Python a good language for beginning programmers? |url=https://docs.python.org/faq/general.html#is-python-a-good-language-for-beginning-programmers |work=General Python FAQ |publisher=Python Software Foundation |access-date=21 March 2007 |archive-date=24 October 2012 |archive-url=https://web.archive.org/web/20121024164224/http://docs.python.org/faq/general.html#is-python-a-good-language-for-beginning-programmers |url-status=live}}</ref> | <ref name="AutoNT-52">{{cite web |title=Is Python a good language for beginning programmers? |url=https://docs.python.org/faq/general.html#is-python-a-good-language-for-beginning-programmers |work=General Python FAQ |publisher=Python Software Foundation |access-date=21 March 2007 |archive-date=24 October 2012 |archive-url=https://web.archive.org/web/20121024164224/http://docs.python.org/faq/general.html#is-python-a-good-language-for-beginning-programmers |url-status=live}}</ref> | ||
<ref name="AutoNT-53">{{cite web |url=http://www.secnetix.de/~olli/Python/block_indentation.hawk |title=Myths about indentation in Python |publisher=Secnetix.de |access-date=19 April 2011 |archive-date=18 February 2018 |archive-url=https://web.archive.org/web/20180218162410/http://www.secnetix.de/~olli/Python/block_indentation.hawk | <ref name="AutoNT-53">{{cite web |url=http://www.secnetix.de/~olli/Python/block_indentation.hawk |title=Myths about indentation in Python |publisher=Secnetix.de |access-date=19 April 2011 |archive-date=18 February 2018 |archive-url=https://web.archive.org/web/20180218162410/http://www.secnetix.de/~olli/Python/block_indentation.hawk }}</ref> | ||
<ref name="AutoNT-55">{{cite web |last=van Rossum |first=Guido |url=http://neopythonic.blogspot.be/2009/04/tail-recursion-elimination.html |title=Tail Recursion Elimination |publisher=Neopythonic.blogspot.be |date=22 April 2009 |access-date=3 December 2012 |archive-date=19 May 2018 |archive-url=https://web.archive.org/web/20180519225253/http://neopythonic.blogspot.be/2009/04/tail-recursion-elimination.html |url-status=live}}</ref> | <ref name="AutoNT-55">{{cite web |last=van Rossum |first=Guido |url=http://neopythonic.blogspot.be/2009/04/tail-recursion-elimination.html |title=Tail Recursion Elimination |publisher=Neopythonic.blogspot.be |date=22 April 2009 |access-date=3 December 2012 |archive-date=19 May 2018 |archive-url=https://web.archive.org/web/20180519225253/http://neopythonic.blogspot.be/2009/04/tail-recursion-elimination.html |url-status=live}}</ref> | ||
| Line 740: | Line 562: | ||
<ref name="AutoNT-60">{{cite web |url=https://www.python.org/dev/peps/pep-0308/ |title=PEP 308 – Conditional Expressions |last1=van Rossum |first1=Guido |last2=Hettinger |first2=Raymond |date=7 February 2003 |work=Python Enhancement Proposals |publisher=Python Software Foundation |access-date=13 July 2011 |archive-date=13 March 2016 |archive-url=https://web.archive.org/web/20160313113147/https://www.python.org/dev/peps/pep-0308/ |url-status=live}}</ref> | <ref name="AutoNT-60">{{cite web |url=https://www.python.org/dev/peps/pep-0308/ |title=PEP 308 – Conditional Expressions |last1=van Rossum |first1=Guido |last2=Hettinger |first2=Raymond |date=7 February 2003 |work=Python Enhancement Proposals |publisher=Python Software Foundation |access-date=13 July 2011 |archive-date=13 March 2016 |archive-url=https://web.archive.org/web/20160313113147/https://www.python.org/dev/peps/pep-0308/ |url-status=live}}</ref> | ||
<ref name="classy">{{cite web |title=The Python Language Reference, section 3.3. New-style and classic classes, for release 2.7.1 |access-date=12 January 2011 |url=https://docs.python.org/reference/datamodel.html#new-style-and-classic-classes |archive-date=26 October 2012 |archive-url=https://web.archive.org/web/20121026063834/http://docs.python.org/reference/datamodel.html#new-style-and-classic-classes }}</ref> | |||
<ref name="classy">{{cite web |title=The Python Language Reference, section 3.3. New-style and classic classes, for release 2.7.1 |access-date=12 January 2011 |url=https://docs.python.org/reference/datamodel.html#new-style-and-classic-classes |archive-date=26 October 2012 |archive-url=https://web.archive.org/web/20121026063834/http://docs.python.org/reference/datamodel.html#new-style-and-classic-classes | |||
<ref name="pep0237">{{cite web |url=https://www.python.org/dev/peps/pep-0237/ |title=PEP 237 – Unifying Long Integers and Integers |last1=Zadka |first1=Moshe |last2=van Rossum |first2=Guido |date=11 March 2001 |work=Python Enhancement Proposals |publisher=Python Software Foundation |access-date=24 September 2011 |archive-date=28 May 2020 |archive-url=https://web.archive.org/web/20200528063237/https://www.python.org/dev/peps/pep-0237/ |url-status=live}}</ref> | <ref name="pep0237">{{cite web |url=https://www.python.org/dev/peps/pep-0237/ |title=PEP 237 – Unifying Long Integers and Integers |last1=Zadka |first1=Moshe |last2=van Rossum |first2=Guido |date=11 March 2001 |work=Python Enhancement Proposals |publisher=Python Software Foundation |access-date=24 September 2011 |archive-date=28 May 2020 |archive-url=https://web.archive.org/web/20200528063237/https://www.python.org/dev/peps/pep-0237/ |url-status=live}}</ref> | ||
| Line 752: | Line 572: | ||
<ref name="AutoNT-64">{{citation |url=https://docs.python.org/py3k/library/functions.html#round |access-date=14 August 2011 |title=round |work=The Python standard library, release 3.2, §2: Built-in functions |archive-date=25 October 2012 |archive-url=https://web.archive.org/web/20121025141808/http://docs.python.org/py3k/library/functions.html#round |url-status=live}}</ref> | <ref name="AutoNT-64">{{citation |url=https://docs.python.org/py3k/library/functions.html#round |access-date=14 August 2011 |title=round |work=The Python standard library, release 3.2, §2: Built-in functions |archive-date=25 October 2012 |archive-url=https://web.archive.org/web/20121025141808/http://docs.python.org/py3k/library/functions.html#round |url-status=live}}</ref> | ||
<ref name="AutoNT-65">{{cite book |title=Python Essential Reference |url=https://archive.org/details/pythonessentialr00beaz_036 |url-access=limited |first1=David M. |last1=Beazley |edition=4th |year=2009 |page=[https://archive.org/details/pythonessentialr00beaz_036/page/n90 66] |publisher=Addison-Wesley Professional |isbn= | <ref name="AutoNT-65">{{cite book |title=Python Essential Reference |url=https://archive.org/details/pythonessentialr00beaz_036 |url-access=limited |first1=David M. |last1=Beazley |edition=4th |year=2009 |page=[https://archive.org/details/pythonessentialr00beaz_036/page/n90 66] |publisher=Addison-Wesley Professional |isbn=978-0-672-32978-4}}</ref> | ||
<ref name="CPL">{{cite book |title=The C Programming Language |first1=Brian W. |last1=Kernighan |first2=Dennis M. |last2=Ritchie |title-link=The C Programming Language |edition=2nd |year=1988 |page=[https://archive.org/details/cprogramminglang00bria/page/206 206]}}</ref> | <ref name="CPL">{{cite book |title=The C Programming Language |first1=Brian W. |last1=Kernighan |first2=Dennis M. |last2=Ritchie |title-link=The C Programming Language |edition=2nd |year=1988 |page=[https://archive.org/details/cprogramminglang00bria/page/206 206]}}</ref> | ||
| Line 777: | Line 597: | ||
<ref name="AutoNT-89">{{cite web |url=https://www.python.org/dev/peps/pep-0333/ |title=PEP 333 – Python Web Server Gateway Interface v1.0 |last=Eby |first=Phillip J. |date=7 December 2003 |work=Python Enhancement Proposals |publisher=Python Software Foundation |access-date=19 February 2012 |archive-date=14 June 2020 |archive-url=https://web.archive.org/web/20200614170344/https://www.python.org/dev/peps/pep-0333/ |url-status=live}}</ref> | <ref name="AutoNT-89">{{cite web |url=https://www.python.org/dev/peps/pep-0333/ |title=PEP 333 – Python Web Server Gateway Interface v1.0 |last=Eby |first=Phillip J. |date=7 December 2003 |work=Python Enhancement Proposals |publisher=Python Software Foundation |access-date=19 February 2012 |archive-date=14 June 2020 |archive-url=https://web.archive.org/web/20200614170344/https://www.python.org/dev/peps/pep-0333/ |url-status=live}}</ref> | ||
<ref name="lj-bdfl-resignation">{{cite magazine |url=https://www.linuxjournal.com/content/guido-van-rossum-stepping-down-role-pythons-benevolent-dictator-life |title=Guido van Rossum Stepping Down from Role as Python's Benevolent Dictator For Life |last=Fairchild |first=Carlie |magazine=Linux Journal |date=12 July 2018 |access-date=13 July 2018 |archive-date=13 July 2018 |archive-url=https://web.archive.org/web/20180713192427/https://www.linuxjournal.com/content/guido-van-rossum-stepping-down-role-pythons-benevolent-dictator-life |url-status=live}}</ref> | <ref name="lj-bdfl-resignation">{{cite magazine |url=https://www.linuxjournal.com/content/guido-van-rossum-stepping-down-role-pythons-benevolent-dictator-life |title=Guido van Rossum Stepping Down from Role as Python's Benevolent Dictator For Life |last=Fairchild |first=Carlie |magazine=Linux Journal |date=12 July 2018 |access-date=13 July 2018 |archive-date=13 July 2018 |archive-url=https://web.archive.org/web/20180713192427/https://www.linuxjournal.com/content/guido-van-rossum-stepping-down-role-pythons-benevolent-dictator-life |url-status=live}}</ref> | ||
| Line 799: | Line 603: | ||
===Sources=== | ===Sources=== | ||
* {{cite web |url=https://wiki.python.org/moin/PythonForArtificialIntelligence |title=Python for Artificial Intelligence |publisher=Python Wiki |date=19 July 2012 |access-date=3 December 2012 | * {{cite web |url=https://wiki.python.org/moin/PythonForArtificialIntelligence |title=Python for Artificial Intelligence |publisher=Python Wiki |date=19 July 2012 |access-date=3 December 2012 |archive-url=https://web.archive.org/web/20121101045354/http://wiki.python.org/moin/PythonForArtificialIntelligence |archive-date=1 November 2012}} | ||
* {{cite journal |editor-last=Paine |editor-first=Jocelyn |title=AI in Python |journal=AI Expert Newsletter |publisher=Amzi! |date=August 2005 |url=http://www.ainewsletter.com/newsletters/aix_0508.htm#python_ai_ai |access-date=11 February 2012 |archive-url=https://web.archive.org/web/20120326105810/http://www.ainewsletter.com/newsletters/aix_0508.htm#python_ai_ai |archive-date=26 March 2012 | * {{cite journal |editor-last=Paine |editor-first=Jocelyn |title=AI in Python |journal=AI Expert Newsletter |publisher=Amzi! |date=August 2005 |url=http://www.ainewsletter.com/newsletters/aix_0508.htm#python_ai_ai |access-date=11 February 2012 |archive-url=https://web.archive.org/web/20120326105810/http://www.ainewsletter.com/newsletters/aix_0508.htm#python_ai_ai |archive-date=26 March 2012 }} | ||
* {{cite web |url=https://pypi.python.org/pypi/PyAIML |title=PyAIML 0.8.5 : Python Package Index |publisher=Pypi.python.org |access-date=17 July 2013}} | * {{cite web |url=https://pypi.python.org/pypi/PyAIML |title=PyAIML 0.8.5: Python Package Index |publisher=Pypi.python.org |access-date=17 July 2013}} | ||
* {{cite book |title=Artificial Intelligence: A Modern Approach |last1=Russell |first1=Stuart J. |author-link1=Stuart J. Russell |last2=Norvig |first2=Peter |author-link2=Peter Norvig |name-list-style=amp |edition=3rd |year=2009 |publisher=Prentice Hall |location=Upper Saddle River, NJ |isbn=978-0-13-604259-4}} | * {{cite book |title=Artificial Intelligence: A Modern Approach |last1=Russell |first1=Stuart J. |author-link1=Stuart J. Russell |last2=Norvig |first2=Peter |author-link2=Peter Norvig |name-list-style=amp |edition=3rd |year=2009 |publisher=Prentice Hall |location=Upper Saddle River, NJ |isbn=978-0-13-604259-4}} | ||
| Line 813: | Line 617: | ||
7. Neutrality on the part of editors is essential. In terms of major debates, items representing all major positions should be included, with annotations indicating the specific POV of each. We may have to work out rules where topic disputes are irreconcilable. | 7. Neutrality on the part of editors is essential. In terms of major debates, items representing all major positions should be included, with annotations indicating the specific POV of each. We may have to work out rules where topic disputes are irreconcilable. | ||
--> | --> | ||
* {{cite book |last=Downey |first=Allen |title=Think Python: How to Think Like a Computer Scientist |edition=3rd |date=July 2024 |publisher=O'Reilly Media |isbn=978- | * {{cite book |last=Downey |first=Allen |title=Think Python: How to Think Like a Computer Scientist |edition=3rd |date=July 2024 |publisher=O'Reilly Media |isbn=978-1-0981-5543-8 |url=https://allendowney.github.io/ThinkPython/}} | ||
* {{cite book |last=Lutz |first=Mark |title=Learning Python |publisher=O'Reilly Media |year=2013 |edition=5th |isbn=978-0-596-15806-4}} | * {{cite book |last=Lutz |first=Mark |title=Learning Python |publisher=O'Reilly Media |year=2013 |edition=5th |isbn=978-0-596-15806-4}} | ||
* {{cite book |last=Summerfield |first=Mark |title=Programming in Python 3 |publisher=Addison-Wesley Professional|year=2009|edition=2nd|isbn=978-0-321-68056-3}} | * {{cite book |last=Summerfield |first=Mark |title=Programming in Python 3 |publisher=Addison-Wesley Professional|year=2009|edition=2nd|isbn=978-0-321-68056-3}} | ||
| Line 831: | Line 635: | ||
{{Sister project links |wikt=no |display=Python |commons=Category:Python (programming language) |b=Python Programming |n=no |s=no |voy=no |species=no |d=Q28865}} | {{Sister project links |wikt=no |display=Python |commons=Category:Python (programming language) |b=Python Programming |n=no |s=no |voy=no |species=no |d=Q28865}} | ||
* {{Official website}} | * {{Official website}} | ||
* [https://docs.python.org/3/ Python documentation] | |||
* [https://docs.python.org/3/tutorial/ The Python Tutorial] | * [https://docs.python.org/3/tutorial/ The Python Tutorial] | ||
Revision as of 06:14, 20 November 2025
Script error: No such module "Unsubst".Template:Short description Script error: No such module "Unsubst". Template:Use American English Script error: No such module "Infobox".Script error: No such module "Check for unknown parameters". Template:Python sidebar
Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation.[1] Python is dynamically type-checked and garbage-collected. It supports multiple programming paradigms, including structured (particularly procedural), object-oriented and functional programming.
Guido van Rossum began working on Python in the late 1980s as a successor to the ABC programming language. Python 3.0, released in 2008, was a major revision and not completely backward-compatible with earlier versions. Beginning with Python 3.5,[2] capabilities and keywords for typing were added to the language, allowing optional static typing.[3] Currently only versions in the 3.x series are supported.
Python has gained widespread use in the machine learning community.[4][5][6][7] It is widely taught as an introductory programming language.[8] Since 2003, Python has consistently ranked in the top ten of the most popular programming languages in the TIOBE Programming Community Index, which ranks based on searches in 24 platforms.[9]
History
Script error: No such module "Labelled list hatnote".
Python was conceived in the late 1980s[10] by Guido van Rossum at Centrum Wiskunde & Informatica (CWI) in the Netherlands.[11] It was designed as a successor to the ABC programming language, which was inspired by SETL,[12] capable of exception handling and interfacing with the Amoeba operating system.[13] Python implementation began in December 1989.[11] Van Rossum first released it in 1991 as Python 0.9.0.[11] Van Rossum assumed sole responsibility for the project, as the lead developer, until 12 July 2018, when he announced his "permanent vacation" from responsibilities as Python's "benevolent dictator for life" (BDFL); this title was bestowed on him by the Python community to reflect his long-term commitment as the project's chief decision-maker.[14] (He has since come out of retirement and is self-titled "BDFL-emeritus".) In January 2019, active Python core developers elected a five-member Steering Council to lead the project.[15][16]
The name Python derives from the British comedy series Monty Python's Flying Circus.[17] (See Template:Section link.)
Python 2.0 was released on 16 October 2000, featuring many new features such as list comprehensions, cycle-detecting garbage collection, reference counting, and Unicode support.[18] Python 2.7's end-of-life was initially set for 2015, and then postponed to 2020 out of concern that a large body of existing code could not easily be forward-ported to Python 3.[19][20] It no longer receives security patches or updates.[21][22] While Python 2.7 and older versions are officially unsupported, a different unofficial Python implementation, PyPy, continues to support Python 2, i.e., "2.7.18+" (plus 3.11), with the plus signifying (at least some) "backported security updates".[23]
Python 3.0 was released on 3 December 2008, and was a major revision and not completely backward-compatible with earlier versions, with some new semantics and changed syntax. Python 2.7.18, released in 2020, was the last release of Python 2.[24] Several releases in the Python 3.x series have added new syntax to the language, and made a few (considered very minor) backward-incompatible changes.
As of November 2025[update]Script error: No such module "Check for unknown parameters"., Python 3.14.0 is the latest stable release, and Python 3.13.9 was released a week later, all older 3.x versions had a security update down to Python 3.9.24 then again with 3.9.25, the final version in 3.9 series. Python 3.10 is, since November 2025, the oldest supported branch.[25] Python 3.15 has an alpha released, and Android has a official downloadable executable available for Python 3.14. Releases receive two years of full support followed by three years of security support.
Design philosophy and features
Python is a multi-paradigm programming language. Object-oriented programming and structured programming are fully supported, and many of their features support functional programming and aspect-oriented programming – including metaprogramming[26] and metaobjects.[27] Many other paradigms are supported via extensions, including design by contract[28][29] and logic programming.[30] Python is often referred to as a 'glue language'[31] because it is purposely designed to be able to integrate components written in other languages.
Python uses dynamic typing and a combination of reference counting and a cycle-detecting garbage collector for memory management.[32] It uses dynamic name resolution (late binding), which binds method and variable names during program execution.
Python's design offers some support for functional programming in the "Lisp tradition". It has filter, map, and reduce functions; list comprehensions, dictionaries, sets, and generator expressions.[33] The standard library has two modules (Template:Codes and Template:Codes) that implement functional tools borrowed from Haskell and Standard ML.[34]
Python's core philosophy is summarized in the Zen of Python (PEP 20) written by Tim Peters, which includes aphorisms such as these:[35]
- Explicit is better than implicit.
- Simple is better than complex.
- Readability counts.
- Special cases aren't special enough to break the rules.
- Although practicality beats purity.
- Errors should never pass silently.
- Unless explicitly silenced.
- There should be one-- and preferably only one --obvious way to do it.
However, Python has received criticism for violating these principles and adding unnecessary language bloat.[36] Responses to these criticisms note that the Zen of Python is a guideline rather than a rule.[37] The addition of some new features had been controversial: Guido van Rossum resigned as Benevolent Dictator for Life after conflict about adding the assignment expression operator in Python 3.8 .[38][39]
Nevertheless, rather than building all functionality into its core, Python was designed to be highly extensible via modules. This compact modularity has made it particularly popular as a means of adding programmable interfaces to existing applications. Van Rossum's vision of a small core language with a large standard library and easily extensible interpreter stemmed from his frustrations with ABC, which represented the opposite approach.[10]
Python claims to strive for a simpler, less-cluttered syntax and grammar, while giving developers a choice in their coding methodology. Python lacks do while loops, which Rossum considered harmful.[40] In contrast to Perl's motto "there is more than one way to do it", Python advocates an approach where "there should be one – and preferably only one – obvious way to do it".[35] In practice, however, Python provides many ways to achieve a given goal. There are at least three ways to format a string literal, with no certainty as to which one a programmer should use.[41] Alex Martelli is a Fellow at the Python Software Foundation and Python book author; he wrote that "To describe something as 'clever' is not considered a compliment in the Python culture."[42]
Python's developers typically prioritise readability over performance. For example, they reject patches to non-critical parts of the CPython reference implementation that would offer increases in speed that do not justify the cost of clarity and readability.[43]Script error: No such module "Unsubst". Execution speed can be improved by moving speed-critical functions to extension modules written in languages such as C, or by using a just-in-time compiler like PyPy. Also, it is possible to transpile to other languages. However, this approach either fails to achieve the expected speed-up, since Python is a very dynamic language, or only a restricted subset of Python is compiled (with potential minor semantic changes).[44]
Python is meant to be a fun language to use. This goal is reflected in the name – a tribute to the British comedy group Monty Python[45] – and in playful approaches to some tutorials and reference materials. For instance, some code examples use the terms "spam" and "eggs" (in reference to a Monty Python sketch), rather than the typical terms "foo" and "bar".[46][47]
A common neologism in the Python community is pythonic, which has a broad range of meanings related to program style: Pythonic code may use Python idioms well; be natural or show fluency in the language; or conform with Python's minimalist philosophy and emphasis on readability.[48]
Syntax and semantics
Script error: No such module "Labelled list hatnote". Python is meant to be an easily readable language. Its formatting is visually uncluttered and often uses English keywords where other languages use punctuation. Unlike many other languages, it does not use curly brackets to delimit blocks, and semicolons after statements are allowed but rarely used. It has fewer syntactic exceptions and special cases than C or Pascal.[49]
Indentation
Script error: No such module "labelled list hatnote".
Python uses whitespace indentation, rather than curly brackets or keywords, to delimit blocks. An increase in indentation comes after certain statements; a decrease in indentation signifies the end of the current block.[50] Thus, the program's visual structure accurately represents its semantic structure.[51] This feature is sometimes termed the off-side rule. Some other languages use indentation this way; but in most, indentation has no semantic meaning. The recommended indent size is four spaces.[52]
Statements and control flow
Python's statements include the following:
- The assignment statement, using a single equals sign
= - The
ifstatement, which conditionally executes a block of code, along withelseandelif(a contraction ofelse if) - The
forstatement, which iterates over an iterable object, capturing each element to a variable for use by the attached block; the variable is not deleted when the loop finishes - The
whilestatement, which executes a block of code as long as boolean condition is true - The
trystatement, which allows exceptions raised in its attached code block to be caught and handled byexceptclauses (or new syntaxexcept*in Python 3.11 for exception groups);[53] thetrystatement also ensures that clean-up code in afinallyblock is always run regardless of how the block exits - The
raisestatement, used to raise a specified exception or re-raise a caught exception - The
classstatement, which executes a block of code and attaches its local namespace to a class, for use in object-oriented programming - The
defstatement, which defines a function or method - The
withstatement, which encloses a code block within a context manager, allowing resource-acquisition-is-initialization (RAII)-like behavior and replacing a common try/finally idiom[54] Examples of a context include acquiring a lock before some code is run, and then releasing the lock; or opening and then closing a file - The
breakstatement, which exits a loop - The
continuestatement, which skips the rest of the current iteration and continues with the next - The
delstatement, which removes a variable—deleting the reference from the name to the value, and producing an error if the variable is referred to before it is redefined Template:Efn - The
passstatement, serving as a NOP (i.e., no operation), which is syntactically needed to create an empty code block - The
assertstatement, used in debugging to check for conditions that should apply - The
yieldstatement, which returns a value from a generator function (and also an operator); used to implement coroutines - The
returnstatement, used to return a value from a function - The
importandfromstatements, used to import modules whose functions or variables can be used in the current program - The
matchandcasestatements, analogous to a switch statement construct, which compares an expression against one or more cases as a control-flow measure
The assignment statement (=) binds a name as a reference to a separate, dynamically allocated object. Variables may subsequently be rebound at any time to any object. In Python, a variable name is a generic reference holder without a fixed data type; however, it always refers to some object with a type. This is called dynamic typing—in contrast to statically-typed languages, where each variable may contain only a value of a certain type.
Python does not support tail call optimization or first-class continuations; according to Van Rossum, the language never will.[55][56] However, better support for coroutine-like functionality is provided by extending Python's generators.[57] Before 2.5, generators were lazy iterators; data was passed unidirectionally out of the generator. From Python 2.5 on, it is possible to pass data back into a generator function; and from version 3.3, data can be passed through multiple stack levels.[58]
Expressions
Python's expressions include the following:
- The
+,-, and*operators for mathematical addition, subtraction, and multiplication are similar to other languages, but the behavior of division differs. There are two types of division in Python: floor division (or integer division)//, and floating-point division/.[59] Python uses the**operator for exponentiation. - Python uses the
+operator for string concatenation. The language uses the*operator for duplicating a string a specified number of times. - The
@infix operator is intended to be used by libraries such as NumPy for matrix multiplication.[60][61] - The syntax
:=, called the "Template:Va", was introduced in Python 3.8. This operator assigns values to variables as part of a larger expression.[62] - In Python,
==compares two objects by value. Python'sisoperator may be used to compare object identities (i.e., comparison by reference), and comparisons may be chained—for example,a <= b <= c. - Python uses
and,or, andnotas Boolean operators. - Python has a type of expression called a list comprehension, and a more general expression called a generator expression.[33]
- Anonymous functions are implemented using lambda expressions; however, there may be only one expression in each body.
- Conditional expressions are written as
x if c else y.[63] (This is different in operand order from thec ? x : yoperator common to many other languages.) - Python makes a distinction between lists and tuples. Lists are written as
[1, 2, 3], are mutable, and cannot be used as the keys of dictionaries (since dictionary keys must be immutable in Python). Tuples, written as(1, 2, 3), are immutable and thus can be used as the keys of dictionaries, provided that all of the tuple's elements are immutable. The+operator can be used to concatenate two tuples, which does not directly modify their contents, but produces a new tuple containing the elements of both. For example, given the variabletinitially equal to(1, 2, 3), executingt = t + (4, 5)first evaluatest + (4, 5), which yields(1, 2, 3, 4, 5); this result is then assigned back tot—thereby effectively "modifying the contents" oftwhile conforming to the immutable nature of tuple objects. Parentheses are optional for tuples in unambiguous contexts.[64] - Python features sequence unpacking where multiple expressions, each evaluating to something assignable (e.g., a variable or a writable property) are associated just as in forming tuple literal; as a whole, the results are then put on the left-hand side of the equal sign in an assignment statement. This statement expects an iterable object on the right-hand side of the equal sign to produce the same number of values as the writable expressions on the left-hand side; while iterating, the statement assigns each of the values produced on the right to the corresponding expression on the left.[65]
- Python has a "string format" operator
%that functions analogously toprintfformat strings in the C language—e.g."spam=%s eggs=%d" % ("blah", 2)evaluates to"spam=blah eggs=2". In Python 2.6+ and 3+, this operator was supplemented by theformat()method of thestrclass, e.g.,"spam={0} eggs={1}".format("blah", 2). Python 3.6 added "f-strings":spam = "blah"; eggs = 2; f'spam={spam} eggs={eggs}'.[66] - Strings in Python can be concatenated by "adding" them (using the same operator as for adding integers and floats); e.g.,
"spam" + "eggs"returns"spameggs". If strings contain numbers, they are concatenated as strings rather than as integers, e.g."2" + "2"returns"22". - Python supports string literals in several ways:
- Delimited by single or double quotation marks; single and double quotation marks have equivalent functionality (unlike in Unix shells, Perl, and Perl-influenced languages). Both marks use the backslash (
\) as an escape character. String interpolation became available in Python 3.6 as "formatted string literals".[66] - Triple-quoted, i.e., starting and ending with three single or double quotation marks; this may span multiple lines and function like here documents in shells, Perl, and Ruby.
- Raw string varieties, denoted by prefixing the string literal with
r. Escape sequences are not interpreted; hence raw strings are useful where literal backslashes are common, such as in regular expressions and Windows-style paths. (Compare "@-quoting" in C#.)
- Delimited by single or double quotation marks; single and double quotation marks have equivalent functionality (unlike in Unix shells, Perl, and Perl-influenced languages). Both marks use the backslash (
- Python has array index and array slicing expressions in lists, which are written as
a[key],a[start:stop]ora[start:stop:step]. Indexes are zero-based, and negative indexes are relative to the end. Slices take elements from the start index up to, but not including, the stop index. The (optional) third slice parameter, called step or stride, allows elements to be skipped or reversed. Slice indexes may be omitted—for example,a[:]returns a copy of the entire list. Each element of a slice is a shallow copy.
In Python, a distinction between expressions and statements is rigidly enforced, in contrast to languages such as Common Lisp, Scheme, or Ruby. This distinction leads to duplicating some functionality, for example:
- List comprehensions vs.
for-loops - Conditional expressions vs.
ifblocks - The
eval()vs.exec()built-in functions (in Python 2,execis a statement); the former function is for expressions, while the latter is for statements
A statement cannot be part of an expression; because of this restriction, expressions such as list and dict comprehensions (and lambda expressions) cannot contain statements. As a particular case, an assignment statement such as a = 1 cannot be part of the conditional expression of a conditional statement.
Typing
Python uses duck typing, and it has typed objects but untyped variable names. Type constraints are not checked at definition time; rather, operations on an object may fail at usage time, indicating that the object is not of an appropriate type. Despite being dynamically typed, Python is strongly typed, forbidding operations that are poorly defined (e.g., adding a number and a string) rather than quietly attempting to interpret them.
Python allows programmers to define their own types using classes, most often for object-oriented programming. New instances of classes are constructed by calling the class, for example, SpamClass() or EggsClass()); the classes are instances of the metaclass type (which is an instance of itself), thereby allowing metaprogramming and reflection.
Before version 3.0, Python had two kinds of classes, both using the same syntax: old-style and new-style.[67] Current Python versions support the semantics of only the new style.
Python supports optional type annotations.[68][69] These annotations are not enforced by the language, but may be used by external tools such as mypy to catch errors. Python includes a module typing including several type names for type annotations.[70][71] Also, Mypy supports a Python compiler called mypyc, which leverages type annotations for optimization.[72]
| Type | Mutability | Description | Syntax examples |
|---|---|---|---|
bool
|
immutable | Boolean value | TrueFalse
|
bytearray
|
mutable | Sequence of bytes | bytearray(b'Some ASCII')bytearray(b"Some ASCII")bytearray([119, 105, 107, 105])
|
bytes
|
immutable | Sequence of bytes | b'Some ASCII'b"Some ASCII"bytes([119, 105, 107, 105])
|
complex
|
immutable | Complex number with real and imaginary parts | 3+2.7j3 + 2.7j5j
|
dict
|
mutable | Associative array (or dictionary) of key and value pairs; can contain mixed types (keys and values); keys must be a hashable type | {'key1': 1.0, 3: False}{}
|
types.EllipsisType
|
immutable | An ellipsis placeholder to be used as an index in NumPy arrays | ...Ellipsis
|
float
|
immutable | Double-precision floating-point number. The precision is machine-dependent, but in practice it is generally implemented as a 64-bit IEEE 754 number with 53 bits of precision.[73] |
|
frozenset
|
immutable | Unordered set, contains no duplicates; can contain mixed types, if hashable | frozenset({4.0, 'string', True})
|
int
|
immutable | Integer of unlimited magnitude[74] | 42
|
list
|
mutable | List, can contain mixed types | [4.0, 'string', True][]
|
types.NoneType
|
immutable | An object representing the absence of a value, often called null in other languages | None
|
types.NotImplementedType
|
immutable | A placeholder that can be returned from overloaded operators to indicate unsupported operand types. | NotImplemented
|
range
|
immutable | An immutable sequence of numbers, commonly used for iterating a specific number of times in for loops[75]
|
range(−1, 10)range(10, −5, −2)
|
set
|
mutable | Unordered set, contains no duplicates; can contain mixed types, if hashable | {4.0, 'string', True}set()
|
str
|
immutable | A character string: sequence of Unicode codepoints | 'Wikipedia'"Wikipedia""""Spanning
multiple
lines"""
|
tuple
|
immutable | Tuple, can contain mixed types | (4.0, 'string', True)('single element',)()
|
Arithmetic operations
Python includes conventional symbols for arithmetic operators (+, -, *, /), the floor-division operator //, and the modulo operator %. (With the modulo operator, a remainder can be negative, e.g., 4 % -3 == -2.) Also, Python offers the ** symbol for exponentiation, e.g. 5**3 == 125 and 9**0.5 == 3.0. Also, it offers the matrix‑multiplication operator @ .[76] These operators work as in traditional mathematics; with the same precedence rules, the infix operators + and - can also be unary, to represent positive and negative numbers respectively.
Division between integers produces floating-point results. The behavior of division has changed significantly over time:[77]
- The current version of Python (i.e., since 3.0) changed the
/operator to always represent floating-point division, e.g.,5/2 == 2.5. - The floor division
//operator was introduced, meaning that7//3 == 2,-7//3 == -3,7.5//3 == 2.0, and-7.5//3 == -3.0. For Python 2.7, adding thefrom __future__ import divisionstatement allows a module in Python 2.7 to use Python 3.x rules for division (see above).
In Python terms, the / operator represents true division (or simply division), while the // operator represents floor division. Before version 3.0, the / operator represents classic division.[77]
Rounding towards negative infinity, though a different method than in most languages, adds consistency to Python. For instance, this rounding implies that the equation (a + b)//b == a//b + 1 is always true. Also, the rounding implies that the equation b*(a//b) + a%b == a is valid for both positive and negative values of a. As expected, the result of a%b lies in the half-open interval [0, b), where b is a positive integer; however, maintaining the validity of the equation requires that the result must lie in the interval (b, 0] when b is negative.[78]
Python provides a round function for rounding a float to the nearest integer. For tie-breaking, Python 3 uses the round to even method: round(1.5) and round(2.5) both produce 2.[79] Python versions before 3 used the round-away-from-zero method: round(0.5) is 1.0, and round(-0.5) is −1.0.[80]
Python allows Boolean expressions that contain multiple equality relations to be consistent with general usage in mathematics. For example, the expression a < b < c tests whether a is less than b and b is less than c.[81] C-derived languages interpret this expression differently: in C, the expression would first evaluate a < b, resulting in 0 or 1, and that result would then be compared with c.[82]
Python uses arbitrary-precision arithmetic for all integer operations. The Decimal type/class in the decimal module provides decimal floating-point numbers to a pre-defined arbitrary precision with several rounding modes.[83] The Fraction class in the fractions module provides arbitrary precision for rational numbers.[84]
Due to Python's extensive mathematics library and the third-party library NumPy, the language is frequently used for scientific scripting in tasks such as numerical data processing and manipulation.[85][86]
Function syntax
Functions are created in Python by using the def keyword. A function is defined similarly to how it is called, by first providing the function name and then the required parameters. Here is an example of a function that prints its inputs:
def printer(input1, input2 = "already there"):
print(input1)
print(input2)
printer("hello")
# Example output:
# hello
# already there
To assign a default value to a function parameter in case no actual value is provided at run time, variable-definition syntax can be used inside the function header.
Code examples
print('Hello, World!')
Program to calculate the factorial of a non-negative integer:
text = input('Type a number, and its factorial will be printed: ')
n = int(text)
if n < 0:
raise ValueError('You must enter a non-negative integer')
factorial = 1
for i in range(2, n + 1):
factorial *= i
print(factorial)
Libraries
Python's large standard library[87] is commonly cited as one of its greatest strengths. For Internet-facing applications, many standard formats and protocols such as MIME and HTTP are supported. The language includes modules for creating graphical user interfaces, connecting to relational databases, generating pseudorandom numbers, arithmetic with arbitrary-precision decimals,[83] manipulating regular expressions, and unit testing.
Some parts of the standard library are covered by specifications—for example, the Web Server Gateway Interface (WSGI) implementation wsgiref follows PEP 333[88]—but most parts are specified by their code, internal documentation, and test suites. However, because most of the standard library is cross-platform Python code, only a few modules must be altered or rewritten for variant implementations.
As of 13 March 2025,[update]Script error: No such module "Check for unknown parameters". the Python Package Index (PyPI), the official repository for third-party Python software, contains over 614,339[89] packages.
Development environments
Script error: No such module "Labelled list hatnote".
MostTemplate:Which? Python implementations (including CPython) include a read–eval–print loop (REPL); this permits the environment to function as a command line interpreter, with which users enter statements sequentially and receive results immediately.[90]
Also, CPython is bundled with an integrated development environment (IDE) called IDLE,[91] which is oriented toward beginners.Script error: No such module "Unsubst".
Other shells, including IDLE and IPython, add additional capabilities such as improved auto-completion, session-state retention, and syntax highlighting.[91][92]
Standard desktop IDEs include PyCharm, Spyder, and Visual Studio Code;Script error: No such module "Unsubst". there are web browser-based IDEs, such as the following environments:
- Jupyter Notebooks, an open-source interactive computing platform;[93]
- PythonAnywhere, a browser-based IDE and hosting environment; and
- Canopy, a commercial IDE from Enthought that emphasizes scientific computing.[94][95]
Implementations
Script error: No such module "Labelled list hatnote".
Reference implementation
CPython is the reference implementation of Python. This implementation is written in C, meeting the C11 standard[96] since version 3.11. Older versions use the C89 standard with several select C99 features, but third-party extensions are not limited to older C versions—e.g., they can be implemented using C11 or C++.[97][98] CPython compiles Python programs into an intermediate bytecode,[99] which is then executed by a virtual machine.[100] CPython is distributed with a large standard library written in a combination of C and native Python.
CPython is available for many platforms, including Windows and most modern Unix-like systems, including macOS (and Apple M1 Macs, since Python 3.9.1, using an experimental installer). Starting with Python 3.9, the Python installer intentionally fails to install on Windows 7 and 8;[101][102] Windows XP was supported until Python 3.5, with unofficial support for VMS.[103] Platform portability was one of Python's earliest priorities.[104] During development of Python 1 and 2, even OS/2 and Solaris were supported;[105] since that time, support has been dropped for many platforms.
All current Python versions (since 3.7) support only operating systems that feature multithreading, by now supporting not nearly as many operating systems (dropping many outdated) than in the past.
Limitations of the reference implementation
- The energy usage of Python with CPython for typically written code is much worse than C by a factor of 75.88.[106]
- The throughput of Python with CPython for typically written code is worse than C by a factor of 71.9.[106]
- The average memory usage of CPython for typically written code is worse than C by a factor of 2.4.[106]
Other implementations
All alternative implementations have at least slightly different semantics. For example, an alternative may include unordered dictionaries, in contrast to other current Python versions. As another example in the larger Python ecosystem, PyPy does not support the full C Python API.
Creating an executable with Python often is done by bundling an entire Python interpreter into the executable, which causes binary sizes to be massive for small programs,[107] yet there exist implementations that are capable of truly compiling Python. Alternative implementations include the following:
- PyPy is a faster, compliant interpreter of Python 2.7 and 3.10.[108][109] PyPy's just-in-time compiler often improves speed significantly relative to CPython, but PyPy does not support some libraries written in C.[110] PyPy offers support for the RISC-V instruction-set architecture.
- Codon is an implementation with an ahead-of-time (AOT) compiler, which compiles a statically-typed Python-like language whose "syntax and semantics are nearly identical to Python's, there are some notable differences"[111] For example, Codon uses 64-bit machine integers for speed, not arbitrarily as with Python; Codon developers claim that speedups over CPython are usually on the order of ten to a hundred times. Codon compiles to machine code (via LLVM) and supports native multithreading.[112] Codon can also compile to Python extension modules that can be imported and used from Python.
- MicroPython and CircuitPython are Python 3 variants that are optimized for microcontrollers, including the Lego Mindstorms EV3.[113]
- Pyston is a variant of the Python runtime that uses just-in-time compilation to speed up execution of Python programs.[114]
- Cinder is a performance-oriented fork of CPython 3.8 that features a number of optimizations, including bytecode inline caching, eager evaluation of coroutines, a method-at-a-time JIT, and an experimental bytecode compiler.[115]
- The Snek[116][117][118] embedded computing language "is Python-inspired, but it is not Python. It is possible to write Snek programs that run under a full Python system, but most Python programs will not run under Snek."[119] Snek is compatible with 8-bit AVR microcontrollers such as ATmega 328P-based Arduino, as well as larger microcontrollers that are compatible with MicroPython. Snek is an imperative language that (unlike Python) omits object-oriented programming. Snek supports only one numeric data type, which features 32-bit single precision (resembling JavaScript numbers, though smaller).
Unsupported implementations
Stackless Python is a significant fork of CPython that implements microthreads. This implementation uses the call stack differently, thus allowing massively concurrent programs. PyPy also offers a stackless version.[120]
Just-in-time Python compilers have been developed, but are now unsupported:
- Google began a project named Unladen Swallow in 2009: this project aimed to speed up the Python interpreter five-fold by using LLVM, and improve multithreading capability for scaling to thousands of cores,[121] while typical implementations are limited by the global interpreter lock.
- Psyco is a discontinued just-in-time specializing compiler, which integrates with CPython and transforms bytecode to machine code at runtime. The emitted code is specialized for certain data types and is faster than standard Python code. Psyco does not support Python 2.7 or later.
- PyS60 was a Python 2 interpreter for Series 60 mobile phones, which was released by Nokia in 2005. The interpreter implemented many modules from Python's standard library, as well as additional modules for integration with the Symbian operating system. The Nokia N900 also supports Python through the GTK widget library, allowing programs to be written and run on the target device.[122]
Transpilers to other languages
There are several compilers/transpilers to high-level object languages; the source language is unrestricted Python, a subset of Python, or a language similar to Python:
- Brython[123] and Transcrypt[124][125] compile Python to JavaScript.
- Cython compiles a superset of Python to C. The resulting code can be used with Python via direct C-level API calls into the Python interpreter.
- PyJL compiles/transpiles a subset of Python to "human-readable, maintainable, and high-performance Julia source code".[44] Despite the developers' performance claims, this is not possible for arbitrary Python code; that is, compiling to a faster language or machine code is known to be impossible in the general case. The semantics of Python might potentially be changed, but in many cases speedup is possible with few or no changes in the Python code. The faster Julia source code can then be used from Python or compiled to machine code.
- Nuitka compiles Python into C.[126] This compiler works with Python 3.4 to 3.13 (and 2.6 and 2.7) for Python's main supported platforms (and Windows 7 or even Windows XP) and for Android. The compiler developers claim full support for Python 3.10, partial support for Python 3.11 and 3.12, and experimental support for Python 3.13. Nuitka supports macOS including Apple Silicon-based versions. The compiler is free of cost, though it has commercial add-ons (e.g., for hiding source code).
- Numba is a JIT compiler that is used from Python; the compiler translates a subset of Python and NumPy code into fast machine code. This tool is enabled by adding a decorator to the relevant Python code.
- Pythran compiles a subset of Python 3 to C++ (C++11).[127]
- RPython can be compiled to C, and it is used to build the PyPy interpreter for Python.
- The Python → 11l → C++ transpiler[128] compiles a subset of Python 3 to C++ (C++17).
There are also specialized compilers:
- MyHDL is a Python-based hardware description language (HDL) that converts MyHDL code to Verilog or VHDL code.
Some older projects existed, as well as compilers not designed for use with Python 3.x and related syntax:
- Google's Grumpy transpiles Python 2 to Go.[129][130][131] The latest release was in 2017.
- IronPython allows running Python 2.7 programs with the .NET Common Language Runtime.[132] An alpha version (released in 2021), is available for "Python 3.4, although features and behaviors from later versions may be included."[133]
- Jython compiles Python 2.7 to Java bytecode, allowing the use of Java libraries from a Python program.[134]
- Pyrex (last released in 2010) and Shed Skin (last released in 2013) compile to C and C++ respectively.
Performance
A performance comparison among various Python implementations, using a non-numerical (combinatorial) workload, was presented at EuroSciPy '13.[135] In addition, Python's performance relative to other programming languages is benchmarked by The Computer Language Benchmarks Game.[136]
There are several approaches to optimizing Python performance, despite the inherent slowness of an interpreted language. These approaches include the following strategies or tools:
- Just-in-time compilation: Dynamically compiling parts of a Python program during the execution of the program. This technique is used in libraries such as Numba and PyPy.
- Static compilation: Sometimes, Python code can be compiled into machine code sometime before execution. An example of this approach is Cython, which compiles Python into C.
- Concurrency and parallelism: Multiple tasks can be run simultaneously. Python contains modules such as `multiprocessing` to support this form of parallelism. Moreover, this approach helps to overcome limitations of the Global Interpreter Lock (GIL) in CPU tasks.
- Efficient data structures: Performance can also be improved by using data types such as
Setfor membership tests, ordequefromcollectionsfor queue operations. - Performance gains can be observed by utilizing libraries such as NumPy. Most high performance Python libraries use C or Fortran under the hood instead of the Python interpreter.[137]
Language Development
Python's development is conducted mostly through the Python Enhancement Proposal (PEP) process; this process is the primary mechanism for proposing major new features, collecting community input on issues, and documenting Python design decisions.[138] Python coding style is covered in PEP 8.[52] Outstanding PEPs are reviewed and commented on by the Python community and the steering council.[138]
Enhancement of the language corresponds with development of the CPython reference implementation. The mailing list python-dev is the primary forum for the language's development. Specific issues were originally discussed in the Roundup bug tracker hosted by the foundation.[139] In 2022, all issues and discussions were migrated to GitHub.[140] Development originally took place on a self-hosted source-code repository running Mercurial, until Python moved to GitHub in January 2017.[141]
CPython's public releases have three types, distinguished by which part of the version number is incremented:
- Backward-incompatible versions, where code is expected to break and must be manually ported. The first part of the version number is incremented. These releases happen infrequently—version 3.0 was released 8 years after 2.0. According to Guido van Rossum, a version 4.0 will probably never exist.[142]
- Major or "feature" releases are largely compatible with the previous version but introduce new features. The second part of the version number is incremented. Starting with Python 3.9, these releases are expected to occur annually.[143][144] Each major version is supported by bug fixes for several years after its release.[145]
- Bug fix releases,[146] which introduce no new features, occur approximately every three months; these releases are made when a sufficient number of bugs have been fixed upstream since the last release. Security vulnerabilities are also patched in these releases. The third and final part of the version number is incremented.[146]
Many alpha, beta, and release-candidates are also released as previews and for testing before final releases. Although there is a rough schedule for releases, they are often delayed if the code is not ready yet. Python's development team monitors the state of the code by running a large unit test suite during development.[147]
The major academic conference on Python is PyCon. Also, there are special Python mentoring programs, such as PyLadies.
Naming
Python's name is inspired by the British comedy group Monty Python, whom Python creator Guido van Rossum enjoyed while developing the language. Monty Python references appear frequently in Python code and culture;[148] for example, the metasyntactic variables often used in Python literature are spam and eggs, rather than the traditional foo and bar.[148][149] Also, the official Python documentation contains various references to Monty Python routines.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".[150] Python users are sometimes referred to as "Pythonistas".[151]
Languages influenced by Python
- Cobra has an Acknowledgements document that lists Python first among influencing languages.[152]
- ECMAScript and JavaScript borrowed iterators and generators from Python.[153]
- Go is designed for "speed of working in a dynamic language like Python".[154]
- Julia was designed to be "as usable for general programming as Python".[155]
- Mojo is almost[156][157] a superset of Python.[158]
- GDScript is strongly influenced by Python. Script error: No such module "Unsubst".
- Groovy, Boo, CoffeeScript, F#, Nim, Ring,[159] Ruby,[160] Swift,[161] and V[162] have been influenced, as well.
See also
Script error: No such module "Portal".
- List of Python programming books
- pip (package manager)
- Pydoc
- NumPy
- SciPy
- Jupyter
- Pytorch
- Cython
- CPython
- Mojo
- Pygame
- PyQt
- PyGTK
- PyPy
- PyCon
- Google ColabTemplate:Snd zero setup online IDE that runs Python
Notes
References
<templatestyles src="Reflist/styles.css" />
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1". Updated as required.
- ↑ Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ a b Script error: No such module "citation/CS1".
- ↑ a b c Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ a b Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ a b Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ a b Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ a b Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ a b Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Cite error: Script error: No such module "Namespace detect".Script error: No such module "Namespace detect".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ a b Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ a b Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ a b Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Cite error: Script error: No such module "Namespace detect".Script error: No such module "Namespace detect".
- ↑ a b c Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ a b Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ a b Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ a b Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Cite error: Script error: No such module "Namespace detect".Script error: No such module "Namespace detect".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Cite error: Script error: No such module "Namespace detect".Script error: No such module "Namespace detect".
- ↑ Script error: No such module "citation/CS1".
- ↑ Cite error: Script error: No such module "Namespace detect".Script error: No such module "Namespace detect".
- ↑ Cite error: Script error: No such module "Namespace detect".Script error: No such module "Namespace detect".
Cite error: <ref> tag with name "98-interview" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "AutoNT-1" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "classmix" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "effbot-call-by-object" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "AutoNT-2" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "AutoNT-3" defined in <references> is not used in prior text.
Cite error: <ref> tag with name "AutoNT-4" defined in <references> is not used in prior text.
<ref> tag with name "AutoNT-6" defined in <references> is not used in prior text.Script error: No such module "Check for unknown parameters".
Sources
- Script error: No such module "citation/CS1".
- Script error: No such module "Citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
Further reading
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
External links
Script error: No such module "Sister project links".Script error: No such module "Check for unknown parameters".
- Script error: No such module "Official website".Script error: No such module "Check for unknown parameters".
- Python documentation
- The Python Tutorial
Script error: No such module "Navbox". Script error: No such module "Navbox". Script error: No such module "Navbox". Template:Differentiable computing Script error: No such module "Navbox". Script error: No such module "Navbox". Script error: No such module "Navbox". Script error: No such module "Authority control".
- Pages with script errors
- Pages with reference errors
- Pages with broken file links
- Articles containing potentially dated statements from November 2025
- Articles with invalid date parameter in template
- All articles containing potentially dated statements
- Articles containing potentially dated statements from March 2025
- Python (programming language)
- Class-based programming languages
- Notebook interface
- Computer science in the Netherlands
- Concurrent programming languages
- Cross-platform free software
- Cross-platform software
- Dutch inventions
- Dynamically typed programming languages
- Educational programming languages
- High-level programming languages
- Information technology in the Netherlands
- Multi-paradigm programming languages
- Object-oriented programming languages
- Pattern matching programming languages
- Programming languages
- Programming languages created in 1991
- Scripting languages
- Text-oriented programming languages
- Monty Python references