Python

Hand-drawn rounded terracotta slabs in stepped stacks over dense flowing sand, umber and moss contour lines.

Python is a programming language that began as a way to write scripts for a research project and is now used in data analysis and research software. It uses dynamic typing, in which an object’s type decides what a program can do with it, and offers optional type hints that checkers read before a program runs. (Venners, 2003b; Python Software Foundation, n.d.e; Python Software Foundation & JetBrains, 2025; Farshidi et al., 2026; van Rossum et al., 2014) In retrospective studies, type checkers detected only some of the known bugs they were tested on. (Khan et al., 2022; Oh & Oh, 2024; Xu et al., 2023)

CPython, the program that runs Python code, compiles programs into bytecode, an internal instruction format. (Python Software Foundation, n.d.g) Comparisons of introductory courses report different results depending on the outcome measured. (Wainer & Xavier, 2018; Gordon et al., 2022) Evidence that other implementations, such as PyPy, run faster and use less energy than CPython is limited to selected benchmarks and Python versions. (van Kempen et al., 2025; Stoico et al., 2025)

Origins and governance

Guido van Rossum designed Python in December 1989 at Centrum Wiskunde & Informatica (CWI) in Amsterdam. He needed a scripting language for the Amoeba project and drew on his experience with the ABC programming language. He made Python easy to extend in response to difficulties he had encountered with ABC. The first public release followed in February 1991. (Centrum Wiskunde & Informatica, 2015; Venners, 2003b)

Python’s core developers chose a five-person steering council after van Rossum stepped down from his decision-making role in July 2018. For Python and CPython, the main way to propose major new features is through a Python Enhancement Proposal (PEP). PEPs gather community input and record design decisions. The council has final authority over proposals and can delegate individual decisions. (van Rossum, 2018; Smith & Stufft, 2018; The Python core team & community, 2018; Warsaw et al., 2000)

The transition to Python 3

Python 3.0 deliberately changed rules that existing Python 2 code depended on. When it arrived in December 2008, for example, it replaced the print statement with a function call, so print "hello" became print("hello"). The project extended the planned end of Python 2 support from 2015 to 2020 after many users stayed on Python 2. Official support for Python 2.7 ended in January 2020. (van Rossum, n.d.; Python Software Foundation, n.d.j; Peterson, 2008)

In a March 2017 sample of 51 applications, many used syntax accepted by both Python 2.7 and 3.5. Others passed the test only in Python 2.7. For each version, the test required that its parser accept at least 99% of an application’s Python files. (Malloy & Power, 2017)

Dynamic typing and type hints

In Python, a name refers to an object, and each object’s type determines which operations it supports. Optional type hints add a separate check before the program runs. (Python Software Foundation, n.d.f; Python Software Foundation, n.d.e) In duck typing, code uses a method or attribute directly, without first checking the type. Code that calls an object’s read() method can use any object that provides that method. (Python Software Foundation, n.d.g)

How common dynamic features are depends on what a study counts. A study of 50 mature Python programs found that changes to objects during execution were common. A study of more than three million Python files on GitHub found that features that hamper code analysis without running the program were uncommon. (Sun et al., 2023b; Yang et al., 2022b)

What type checkers examine

Python 3.5 introduced standard type hints, annotations that describe the types code expects, for optional static checking. A static type checker uses them to look for mismatches without running the program. Developers can annotate part of a program and leave the rest unannotated, an approach called gradual typing. (van Rossum et al., 2014; van Rossum & Levkivskyi, 2014) Python 3.8 added protocols, which bring duck typing to the checker. A protocol lists the methods or attributes a use requires, and any class that provides them satisfies it without declaring so. (Levkivskyi et al., 2017)

Python 3.14 does not enforce function and variable annotations when a program runs. (Python Software Foundation, n.d.q) It also normally waits until annotations on functions, classes and modules are needed to evaluate them. (Turner & van Kemenade, n.d.)

What a checker covers depends on the tool and its settings. Mypy 2.4.1 normally skips the bodies of functions with no annotations at all, unless the --check-untyped-defs option is set. (mypy contributors, n.d.) Pyright offers four rule sets, called off, basic, standard and strict, and defaults to standard. (Microsoft, n.d.c)

Where annotations appear

Annotation use varies with the projects measured. Among 9,655 popular Python repositories on GitHub created from 2010 to 2019, 668 (7%) used any type annotations. (Di Grazia & Pradel, 2022) Within TensorFlow, the share of annotated Python functions rose from 4.99% in 2019 to 39.12% in 2022. (Lin et al., 2023c)

Annotations can themselves be wrong. A study of annotation-related defects identified four categories, including inconsistent annotations and insufficient safety checks. (Lin et al., 2023c)

Which defects checkers detect Strong evidence: many studies agree on this

A few retrospective studies found that static checkers caught some Python bugs that were already fixed or confirmed. The studies counted different kinds of defects and supplied annotations under different conditions, and they measured detection only after the bugs were known. (Khan et al., 2022; Oh & Oh, 2024; Xu et al., 2023)

ProjectsWhat researchers countedDefects detected
210 GitHub projectsFixed public defects, with type annotations added by researchers; private and unfixed defects excludedMypy could have caught an estimated 15% of defects classified as corrective and 11% of all sampled defects (Khan et al., 2022)
20 open-source projects68 developer-confirmed type errorsMypy, Pytype, Pyre and Pyright together detected 16 of 68 (Oh & Oh, 2024)
10 Python projectsThe same 40 known type-related bugs, before and after researchers added annotationsThree checkers together detected 14 of 40 before the additions and 29 of 40 afterward (Xu et al., 2023)

Python written by coding agents

Errors in snippets, functions and classes Weak evidence: few or small studies support this

Error rankings in generated Python depend on the task and how failures are measured. A lint finding marks code that matches a rule, while a failed test records what happened during execution. Manual classification can instead count mistakes in what the code was written to do. (Zhong et al., 2026a; Tambon et al., 2024; Rahman et al., 2025b)

SettingWhat was countedCommon findings
CodeChat, first responses in coding conversations of at least five turnsShare of first-turn Python snippets flagged by PylintUndefined variables (30.8%), import errors (20.8%) and syntax errors (8.0%) (Zhong et al., 2026a)
CoderEval, generated Python functionsShare of manually classified bug labelsMisinterpretation of the task (20.77%) and missed cases at the limits of the expected behaviour (15.27%) (Tambon et al., 2024)
RealClassEval, two class datasets drawn from repositoriesShare of errors recorded in failed test casesAttributeError (45.67–49.41%) and TypeError (22.14–23.78%) (Rahman et al., 2025b)

Dependencies and library versions Weak evidence: few or small studies support this

Generated projects can omit a dependency even when they run successfully. Of 120 Python projects produced by three agents, 107 ran as supplied in a clean environment and 11 omitted a dependency declaration. Another package can bring in an undeclared dependency, allowing execution to succeed. (Vangala et al., 2025)

Generated calls can use a library interface that has been marked for replacement. Seven models tested on eight Python libraries still suggested deprecated calls when the prompt showed up-to-date code. Across models, deprecated calls accounted for 9–18% of completions that used either the older call or its replacement. (Wang et al., 2025e)

Starting a project in a clean environment checks whether it can run with the supplied dependencies. Griffe compares the source of two library versions to detect changes that break the public interface. (Vangala et al., 2025; Griffe developers, n.d.)

Configured lint and type checks

Lint and type checks flag different problems before execution. Ruff has rules for undefined names and bare except clauses, which specify no exception type. Mypy can detect calls with incompatible argument types and uses of missing attributes. (Astral, n.d.a; Dong et al., 2025b)

Which lint findings appear depends on the rules in force for the project. Ruff combines settings from project configuration, inherited configuration and command-line options when it selects rules. (Astral, n.d.b)

Some annotations narrow what a checker can establish. The checker treats an expression typed as Any as having an unknown type, so it cannot verify operations on that expression. A cast tells the checker to assume a particular type and returns the original value at runtime. (Python Software Foundation, n.d.l; Python Software Foundation, n.d.k)

Type checkers can also spot some mistakes in asynchronous code. Pyright can flag a call that discards a coroutine, an object representing work that can be awaited. This catches some omissions of await. (Microsoft, n.d.c)

Focused tests and error paths

Python tests can exercise selected behaviour and repeat the same check with several inputs. Pytest can select tests by keyword or run a single test function with several sets of arguments. (pytest developers, n.d.a; pytest developers, n.d.b)

Coverage of agent-written changes

Weak evidence

Tests that accompany agent changes often leave error-handling code unexercised. In one study, adding the agent’s tests increased the share of changed lines executed in 136 of 605 Python pull requests that changed code and tests. The suites missed 81.0% of newly added executable lines classified as part of try/except constructs. (Dipongkor et al., 2026)

Property tests

A property test checks a rule across many generated inputs. For example, decoding an encoded value should recover the original. Hypothesis can also generate sequences of actions to exercise a program whose behaviour depends on earlier actions. (The Hypothesis team, n.d.c; Hypothesis developers, n.d.)

Hypothesis can limit the number of generated cases and the number of steps in each sequence. After finding a failure, it can run extra calls to simplify or explain the failing case. (The Hypothesis team, n.d.a; The Hypothesis team, n.d.b)

Fault detection in property tests

Weak evidence

Property tests catch more deliberately introduced faults per test than unit tests. In one benchmark of 40 Python suites using Hypothesis, an average property test caught about 50 times as many of these changes as an average unit test. (Ravi & Coblenz, 2025)

Bounded contract checks

A contract states a condition that code must satisfy, such as the result a function must return for a given input. CrossHair searches for inputs that break a contract in code that behaves the same way given the same starting values. It can bound CPU time per condition, and a search that finds no counterexample leaves the property unproven. (CrossHair developers, n.d.a; CrossHair developers, n.d.b)

How CPython runs Python

Bytecode and the virtual machine

CPython 3.14 first compiles Python source into bytecode, a set of instructions for the interpreter. The virtual machine is the part of the interpreter that runs those instructions. (Python Software Foundation, n.d.g) The bytecode is internal to CPython and can change between releases. (Python Software Foundation, n.d.n)

The global interpreter lock

In a CPython interpreter with the global interpreter lock (GIL), only one thread, or path of execution, can run Python bytecode at a time. The lock simplifies how CPython protects its internal objects from concurrent access, including built-in types such as dictionaries. (Python Software Foundation, n.d.g) The default build in Python 3.14 still uses the GIL. (Python Software Foundation, n.d.i)

Free threading in Python 3.13 and 3.14

A free-threaded build, which runs without the GIL, became officially supported in Python 3.14 but remains optional. Python 3.13 had offered it as an option in the official macOS and Windows installers. (Python Software Foundation, n.d.i; Turner & van Kemenade, n.d.) PEP 779, the proposal that set the criteria for support, deferred the decision on making it the default. (Wouters et al., 2025)

Extensions written against Python’s C interface can bring the lock back. Importing one that has yet to declare support for free threading may automatically enable the GIL. (Python Software Foundation, n.d.i)

The free-threaded build costs memory and some single-threaded speed. It typically uses more memory than the default build. On the pyperformance benchmarks, single-threaded runs averaged about 1% longer on ARM-based macOS and 8% longer on x86-64 Linux. (Python Software Foundation, n.d.i) An earlier prototype based on Python 3.12 showed 5% to 6% single-threaded overhead on two processor architectures. (Gross, 2023)

Execution time and energy use

Other Python implementations ran faster and used less energy than CPython, but only in tests limited to selected benchmarks and Python versions. On programs from the Computer Language Benchmarks Game that ran on both, PyPy 7.3.17 used about 80% of the time and energy of CPython 3.12.6 on average. (van Kempen et al., 2025) In a separate seven-test comparison, PyPy, Codon and Numba used over 90% less time and energy than CPython on most tests. Those programs ran on one thread without third-party libraries. They used Python 3.10, apart from an experimental just-in-time compiler from Python 3.13, which compiles code while the program runs. (Stoico et al., 2025)

Under controlled conditions, energy use followed running time. With runs limited to one processor core at its minimum frequency, the implementations drew nearly the same power, so shorter runs used less energy. (van Kempen et al., 2025)

Benchmark collections differ in the work they cover. An earlier energy ranking drew on two collections of programming tasks, the Computer Language Benchmarks Game and Rosetta Code. (Pereira et al., 2021) The LangBench suite ran CPython 3.8.1 on six applications with different demands for processing, memory, input and output, and concurrent work. (Lion et al., 2022)

Packages and virtual environments

A virtual environment is a self-contained directory for a particular Python version and additional packages, which are bundles of reusable code. It gives each project a place for the packages it needs. The tool pip installs, updates and removes packages. Its default source is the Python Package Index (PyPI). (Python Software Foundation, n.d.m)

An analysis of package source code flagged potential configuration issues in 183,864 of the 338,069 library releases it checked on PyPI. (Peng et al., 2024)

Fields of use

In the 2024 Python Developers Survey, 51% of respondents reported doing data exploration and processing. The survey was promoted through Python Software Foundation channels and retained more than 25,000 responses after filtering. (Python Software Foundation & JetBrains, 2025)

Python also appears in research software. It was the most common language in a sample of 1,510 open-source research software repositories listed on Zenodo, a research repository. It appeared in 509 repositories, or about 34% of the sample. (Farshidi et al., 2026)

Python in introductory courses

Course comparisons disagree: they favored Python on some outcomes but not others. The comparisons used different languages and measured different outcomes, including exam grades, exercise time and error rates. (Wainer & Xavier, 2018; Gordon et al., 2022; Lokkila et al., 2023)

ComparisonWhat the study found
Python and C, 391 students at the University of CampinasStudents taught in Python earned higher exam grades. Dropout rates were similar. (Wainer & Xavier, 2018)
Python, C++ and Java, 6,804 students across 56 coursesOn similar assignments, students in Python courses had no reduction in median time or number of attempts. (Gordon et al., 2022)
Python and Java, 715 students across four coursesSubmissions in the two Python courses had lower error rates than those in the two Java courses. (Lokkila et al., 2023)

Further reading

Known gaps

What this article cannot tell you yet.

  1. The causes of Python adoption beyond the surveyed developers and sampled repositories remain open.
  2. The course comparisons leave open how much language choice, course design and assessment contribute to learning and whether differences carry over to later courses.
  3. How many defects static type checkers prevent in ordinary Python development remains open.
  4. Whether adding annotations to existing code lets checkers find more bugs than the 40 known bugs studied showed remains open.
  5. The speed and energy comparisons cover selected benchmarks. How alternative runtimes and free-threaded CPython compare on representative applications with third-party dependencies remains open.
  6. How often coding agents introduce particular Python faults in ordinary repository changes remains open.
  7. How much property tests improve detection of real Python bugs at comparable writing and execution costs remains open.
  8. How much work it takes to maintain executable contracts in ordinary Python projects remains open.

References

Solid source
Rated highly trustworthy by the research, and every passage taken from it was found in it.
Weak source
Rated low, or a passage taken from it was not found in it.
Medium trust
Rated medium by the research.
Not checked
Rated high, but its passages could not all be checked against it.
Show all 63 references