Python comparison matrix
A comparison matrix detailing various versions of CPython, including release dates and type information for different data types.
Content article
The Python comparison matrix evaluates various Python implementations, including CPython, Jython, IronPython, and PyPy, across multiple categories such as built-in features, keywords, modules, command line switches, platforms, and features, spanning Python versions from 1.5 to 3.2.
In the "Builtins" tab, several built-in types are compared across different implementations. For instance, the `memoryview` type is supported in CPython starting from version 2.7, while the `set` type was introduced in CPython 2.6, showing a count of 218. The `str` type has been consistently supported across all implementations, with additional enhancements noted by asterisks for versions 3.0 and above. The `bool` type is present in CPython since version 2.3, with a notable usage count of 285. Other types like `dict`, `list`, and `tuple` show varying levels of support across the implementations, with many marked as unsupported in certain versions.
The "Keywords" section lists keywords available in the different implementations. The keyword `and` is universally supported across all versions, while `as` has been supported since version 2.0 in CPython but is marked as unsupported in Jython. The `with` keyword, which simplifies resource management, has been supported since CPython 2.5, with its usage noted in various versions. Keywords like `global`, `if`, and `import` show consistent support across the board, while `nonlocal` is only supported in later versions.
In the "Modules" tab, the matrix highlights the standard library modules available across the different Python implementations. For example, the `abc` module was introduced in CPython 3.0, while the `_winreg` module is specific to CPython's Windows implementation. The `argparse` module, which provides a command-line argument parsing functionality, is supported starting from version 2.7 in CPython. Meanwhile, modules like `audiodev` and `audioop` are noted for their varying support across different platforms.
The "Command line" section details the command line switches available for different Python versions. The `-c <command>` switch is supported from CPython 1.5 onward, allowing users to execute commands directly from the command line. The `-m <module>` switch, which runs a library module as a script, has been available since version 2.7. Additionally, the `-h` or `--help` switch is universally supported, providing help information across all implementations.
In the "Platforms" section, the supported platforms for each implementation are listed. CPython supports a wide range of platforms, including various versions of Windows, Linux distributions, and macOS. Notably, Windows XP/2003 is supported across multiple versions, while newer platforms like Windows Vista/2008/7 show varied support. Linux distributions such as Debian and Ubuntu are also detailed, with specific version compatibility noted for Python 2.7 and 3.x.
The "Features" tab outlines significant features across Python versions. List comprehensions are supported in CPython from version 2.0, while generator expressions were introduced in version 2.4. The `print()` function, which became a built-in function in Python 3, is noted for its transition from a statement in earlier versions. Exception handling features have evolved, with unified try-except-finally constructs introduced in Python 3. The tab also highlights the introduction of decorators for functions and methods, which became available in version 2.4.
Lastly, the "Key" section provides a legend for understanding the support status of various features and modules, indicating whether they are supported, deprecated, or optional in specific versions. Symbols like `/` denote support, while `*` indicates that the feature is supported but has changed semantics in later versions.
The matrix serves as a comprehensive reference for developers looking to understand the differences and capabilities of various Python implementations across multiple versions.