Python

From WikiTech, the encyclopedia of technology

Technology · Programming & Languages · 5 min read · 945 words · Updated

Python
Technology
Python — article photograph or illustration
Image placeholderPlace the file shown below in the assets/articles folder
File: python.webp
Designed byGuido van Rossum
First release1991
TypingDynamic, strong
Websitepython.org

Python is a general-purpose programming language. It uses indentation to delimit blocks and supports object-oriented, procedural and functional styles.

History

Guido van Rossum began Python in December 1989 at CWI in the Netherlands. Version 0.9.0 was released in February 1991, Python 2.0 in 2000 and Python 3.0 in December 2008. Python 2 reached end of life on 1 January 2020.

Architecture

The reference implementation, CPython, compiles source to bytecode executed by a virtual machine. Memory is managed with reference counting and a cycle collector (see Garbage Collection). The global interpreter lock (GIL) has historically allowed only one thread to execute Python bytecode at a time.

def fib(n):
    a, b = 0, 1
    for _ in range(n):
        a, b = b, a + b
    return a

print(fib(10))  # 55

Key mechanisms

Notable features include dynamic typing with optional type hints, generators, decorators, context managers and a large standard library.

Adoption

Python is widely used in scientific computing, machine learning, automation and web back ends. Packages are distributed through PyPI and installed with pip.

Ecosystem

Compared with Rust, Python favours development speed over runtime speed.

Comparison with alternatives

Pure Python code runs slower than compiled languages, and the GIL limits CPU-bound multithreading.

Language model and execution

Python is often described as an interpreted language, although implementations may compile source code to bytecode before executing it. In CPython, the commonly used reference implementation, source files are compiled into bytecode that a virtual machine evaluates. Other implementations, such as PyPy, use different execution techniques. This distinction matters because language behaviour is specified separately from the internal runtime used to execute it.

Python's dynamic type system allows a variable to refer to values of different types at different points in a program. This can make short scripts quick to write, but it also means that certain errors are detected only when the relevant code runs. Type annotations can document expected inputs and outputs, and static analysis tools can check many of those expectations before execution. Annotations do not automatically enforce types at runtime.

Functions, objects and expressive features

Functions are first-class objects, which means they can be assigned to variables, passed as arguments and returned from other functions. Decorators provide a concise way to wrap or modify functions and classes. Generators produce values lazily, which can reduce memory use when processing large sequences. Context managers provide a structured way to acquire and release resources such as files, locks and network connections.

Python also supports object-oriented programming through classes, inheritance and special methods. The language does not require every program to use classes: small scripts often work well with functions and simple data structures. Its flexibility is one reason it is used in education and rapid prototyping, though large projects benefit from agreed conventions and clear module boundaries.

Libraries and package management

Python's standard library covers files, dates, networking, compression, data formats, concurrency and many other common tasks. Third-party packages extend the language into web development, scientific computing, automation and machine learning. PyPI acts as a public package index, while pip installs packages and their dependencies. Virtual environments isolate project dependencies so that one application's libraries do not unintentionally change another's runtime.

Dependency management is an important part of reliable Python development. Projects commonly record versions in lock files or requirements lists, review package provenance and update dependencies to receive security fixes. A package from the public index is still third-party code and should be treated with appropriate care.

Concurrency and performance

Python offers threads, processes and asynchronous programming, each suited to different workloads. Threads are useful for coordinating I/O-bound tasks, while multiprocessing can use multiple CPU cores by running separate processes. The traditional CPython global interpreter lock has limited parallel execution of Python bytecode in a single interpreter, although native extensions can release the lock and alternative runtime configurations continue to evolve.

The asyncio library provides an event-loop model for handling many I/O operations without dedicating a thread to each connection. It is useful when libraries support asynchronous operations, but it does not automatically speed up CPU-heavy calculations. Performance-critical code may use vectorised libraries, compiled extensions or a different implementation language.

Where Python is used

Python is common in data analysis, machine learning, scientific research, scripting, education and web back ends. Its clear syntax makes it useful for explaining programming concepts, while its broad ecosystem helps teams move from prototypes to production systems. Frameworks such as Django and FastAPI support web services, and scientific libraries provide efficient operations on arrays and large datasets.

The same breadth can create complexity. Python projects need testing, type checking where useful, logging, packaging and deployment practices. Developers should also understand the runtime version and dependencies used in production. Python favours readability and developer productivity, but dependable software still requires sound engineering practices.

Testing and maintainability

Python's speed of development can make it tempting to postpone structure, but reliable projects benefit from automated tests and clear interfaces. Unit tests check small pieces of behaviour, integration tests cover interactions between components, and type checkers can catch mismatches before code is executed. Linters and formatters help teams maintain a consistent style. These tools do not replace code review, but they reduce avoidable mistakes and make a dynamic language more predictable as a project grows.

Editorial connections and engineering implications

A Python application depends on more than source files: interpreter version, packages, operating-system libraries and runtime configuration all affect behaviour. Virtual environments isolate dependencies, while lock files or pinned requirements improve reproducibility. Package updates should be tested because they can fix security issues, add features or break compatibility. The public package index is useful, but third-party dependencies still need review.

Python offers threads, processes and asynchronous programming, each suited to different workloads. Threads often help with I/O-bound tasks, processes can execute CPU-heavy work in parallel, and asyncio coordinates many pending operations when libraries support it. Adding async does not make CPU-bound calculations faster. Type hints support documentation and static analysis, but do not enforce types at runtime. Python often coordinates native components written in C, C++ or Rust.

See also

  • C (programming language) – A general-purpose, statically typed systems programming language created at Bell Labs in the early 1970s.
  • Rust – A compiled systems programming language that enforces memory safety through ownership and borrowing without a garbage collector.
  • C++ – A general-purpose, statically typed language that extends C with classes, templates and zero-overhead abstractions.
  • Garbage Collection – Automatic memory management in which a runtime reclaims memory that a program can no longer reach.
  • Guido van Rossum – Dutch programmer who created the Python programming language.
  • ASCII – A 7-bit character encoding that assigns numbers to 128 letters, digits, symbols and control codes.
  • Big-O Notation – A notation describing how the resource use of an algorithm grows as the input size grows.
  • Event Loop – A programming construct that waits for and dispatches events or messages in a single thread of control.

References

  1. ↑ Python Documentation (docs.python.org)