Python is an interpreted, interactive, object-oriented programming language. It incorporates modules, exceptions, dynamic typing, very high level dynamic data types, and classes. It supports multiple programming paradigms beyond object-oriented programming, such as procedural and functional programming.

Python combines remarkable power with very clear syntax. It has interfaces to many system calls and libraries, as well as to various window systems, and is extensible in C or C++. It is also usable as an extension language for applications that need a programmable interface. Finally, Python is portable: it runs on many Unix variants including Linux and macOS, and on Windows.

Features

  • Very clear, readable syntax
  • Strong introspection capabilities
  • Intuitive object orientation
  • Natural expression of procedural code
  • Full modularity, supporting hierarchical packages
  • Exception-based error handling
  • Very high level dynamic data types
  • Extensive standard libraries and third party modules for virtually every task
  • Extensions and modules easily written in C, C++ (or Java for Jython, or .NET languages for IronPython)
  • Embeddable within applications as a scripting interface

Python is powerful... and fast

Fans of Python use the phrase "batteries included" to describe the standard library, which covers everything from asynchronous processing to zip files. The language itself is a flexible powerhouse that can handle practically any problem domain. Build your own web server in three lines of code. Build flexible data-driven code using Python's powerful and dynamic introspection capabilities and advanced language features such as meta-classes, duck typing and decorators.

Python lets you write the code you need, quickly. And, thanks to a highly optimized byte compiler and support libraries, Python code runs more than fast enough for most applications. The traditional implementation of CPython uses a bytecode virtual machine; PyPy supports just-in-time (JIT) compilation to machine code. Also, Jython and IronPython (see below) support JIT compilation on their respective virtual machine implementations.

Python plays well with others

Python can integrate with COM, .NET, and CORBA objects.

For Java libraries, use Jython, an implementation of Python for the Java Virtual Machine.

For .NET, try IronPython , Microsoft's new implementation of Python for .NET, or Python for .NET.

Python is also supported for the Internet Communications Engine (ICE) and many other integration technologies.

If you find something that Python cannot do, or if you need the performance advantage of low-level code, you can write extension modules in C or C++, or wrap existing code with SWIG or Boost.Python. Wrapped modules appear to your program exactly like native Python code. That's language integration made easy. You can also go the opposite route and embed Python in your own application, providing your users with a language they'll enjoy using.

Python runs everywhere

Python is available for all major operating systems: Windows, Linux/Unix, OS/2, Mac, Amiga, among others. There are even versions that run on .NET and the Java virtual machine. You'll be pleased to know that the same source code will run unchanged across all implementations.

Your favorite system isn't listed here? It may still support Python if there's a C compiler for it. Ask around on news:comp.lang.python - or just try compiling Python yourself.

Python is friendly... and easy to learn

The Python newsgroup is known as one of the friendliest around. The avid developer and user community maintains a wiki, hosts international and local conferences, runs development sprints, and contributes to online code repositories.

Python also comes with complete documentation, both integrated into the language and as separate web pages. Online tutorials target both the seasoned programmer and the newcomer. All are designed to make you productive quickly. The availability of first-rate books completes the learning package.

Python is Open

The Python implementation is under an open source license that makes it freely usable and distributable, even for commercial use. The Python license is administered by the Python Software Foundation.

Take a look at application domains where Python is used, or try the current download for yourself.

What's New

Security

  • gh-104049: Do not expose the local on-disk location in directory indexes produced by http.client.SimpleHTTPRequestHandler.

Core and Builtins

  • gh-104018: Disallow the "z" format specifier in %-format of bytes objects.
  • gh-103971: Fix an issue where incorrect locations numbers could be assigned to code following case blocks.
  • gh-102310: Change the error range for invalid bytes literals.
  • gh-103590: Do not wrap a single exception raised from a try-except* construct in an ExceptionGroup.
  • gh-101517: Fix bug in line numbers of instructions emitted for except*.
  • gh-103242: Migrate set_ecdh_curve() method not to use deprecated OpenSSL APIs. Patch by Dong-hee Na.
  • gh-102700: Allow built-in modules to be submodules. This allows submodules to be statically linked into a CPython binary.
  • gh-99184: Bypass instance attribute access of __name__ in repr of weakref.ref.
  • gh-96670: The parser now raises SyntaxError when parsing source code containing null bytes. Backported from aab01e3. Patch by Pablo Galindo
  • bpo-31821: Fix pause_reading() to work when called from connection_made() in asyncio.

Library

  • gh-104035: Do not ignore user-defined __getstate__ and __setstate__ methods for slotted frozen dataclasses.
  • gh-103935: Use io.open_code() for files to be executed instead of raw open()
  • gh-100370: Fix potential OverflowError in sqlite3.Connection.blobopen() for 32-bit builds. Patch by Erlend E. Aasland.
  • gh-103872: Update the bundled copy of pip to version 23.1.2.
  • gh-103685: Prepare tkinter.Menu.index() for Tk 8.7 so that it does not raise TclError: expected integer but got "" when it should return None.
  • gh-81403: urllib.request.CacheFTPHandler no longer raises URLError if a cached FTP instance is reused. ftplib's endtransfer method calls voidresp to drain the connection to handle FTP instance reuse properly.
  • gh-103578: Fixed a bug where pdb crashes when reading source file with different encoding by replacing io.open() with io.open_code(). The new method would also call into the hook set by PyFile_SetOpenCodeHook().
  • gh-103556: Now creating inspect.Signature objects with positional-only parameter with a default followed by a positional-or-keyword parameter without one is impossible.
  • gh-103559: Update the bundled copy of pip to version 23.1.1.
  • gh-103365: Set default Flag boundary to STRICT and fix bitwise operations.
  • gh-103472: Avoid a potential ResourceWarning in http.client.HTTPConnection by closing the proxy / tunnel's CONNECT response explicitly.
  • gh-103449: Fix a bug in doc string generation in dataclasses.dataclass().
  • gh-103256: Fixed a bug that caused hmac to raise an exception when the requested hash algorithm was not available in OpenSSL despite being available separately as part of hashlib itself. It now falls back properly to the built-in. This could happen when, for example, your OpenSSL does not include SHA3 support and you want to compute hmac.digest(b'K', b'M', 'sha3_256').
  • gh-103225: Fix a bug in pdb when displaying line numbers of module-level source code.
  • gh-93910: Remove deprecation of enum memmber.member access.
  • gh-102953: The extraction methods in tarfile, and shutil.unpack_archive(), have a new a filter argument that allows limiting tar features than may be surprising or dangerous, such as creating files outside the destination directory. See Extraction filters for details.
  • gh-101640: argparse.ArgumentParser now catches errors when writing messages, such as when sys.stderr is None. Patch by Oleg Iarygin.

Tests

  • gh-103329: Regression tests for the behaviour of unittest.mock.PropertyMock were added.
  • gh-75729: Fix the os.spawn* tests failing on Windows when the working directory or interpreter path contains spaces.

Build

  • gh-104106: Add gcc fallback of mkfifoat/mknodat for macOS. Patch by Dong-hee Na.
  • gh-99069: Extended workaround defining static_assert when missing from the libc headers to all clang and gcc builds. In particular, this fixes building on macOS <= 10.10.

Windows

  • gh-102997: Update Windows installer to use SQLite 3.41.2.
  • gh-88013: Fixed a bug where TypeError was raised when calling ntpath.realpath() with a bytes parameter in some cases.

macOS

  • gh-102997: Update macOS installer to SQLite 3.41.2.

IDLE

  • gh-88496: Fix IDLE test hang on macOS.

Previous Release Notes:

Core and Builtins

  • gh-92173: Fix the defs and kwdefs arguments to PyEval_EvalCodeEx() and a reference leak in that function.
  • gh-101400: Fix wrong lineno in exception message on continue or break which are not in a loop. Patch by Dong-hee Na.
  • gh-101372: Fix is_normalized() to properly handle the UCD 3.2.0 cases. Patch by Dong-hee Na.
  • gh-101046: Fix a possible memory leak in the parser when raising MemoryError. Patch by Pablo Galindo
  • gh-101037: Fix potential memory underallocation issue for instances of int subclasses with value zero.
  • gh-100942: Fixed segfault in property.getter/setter/deleter that occurred when a property subclass overrode the __new__ method to return a non-property instance.
  • gh-100892: Fix race while iterating over thread states in clearing threading.local. Patch by Kumar Aditya.
  • gh-100776: Fix misleading default value in input()'s __text_signature__.
  • gh-100637: Fix int.__sizeof__() calculation to include the 1 element ob_digit array for 0 and False.
  • gh-100649: Update the native_thread_id field of PyThreadState after fork.
  • gh-100374: Fix incorrect result and delay in socket.getfqdn(). Patch by Dominic Socular.
  • gh-99110: Initialize frame->previous in frameobject.c to fix a segmentation fault when accessing frames created by PyFrame_New().
  • gh-100050: Honor existing errors obtained when searching for mismatching parentheses in the tokenizer. Patch by Pablo Galindo
  • bpo-32782: ctypes arrays of length 0 now report a correct itemsize when a memoryview is constructed from them, rather than always giving a value of 0.

Library

  • gh-101541: [Enum] - fix psuedo-flag creation
  • gh-101326: Fix regression when passing None as second or third argument to FutureIter.throw.
  • gh-100795: Avoid potential unexpected freeaddrinfo call (double free) in socket when when a libc getaddrinfo() implementation leaves garbage in an output pointer when returning an error. Original patch by Sergey G. Brester.
  • gh-101143: Remove unused references to TimerHandle in asyncio.base_events.BaseEventLoop._add_callback.
  • gh-101144: Make zipfile.Path.open() and zipfile.Path.read_text() also accept encoding as a positional argument. This was the behavior in Python 3.9 and earlier. 3.10 introduced a regression where supplying it as a positional argument would lead to a TypeError.
  • gh-101015: Fix typing.get_type_hints() on '*tuple[...]' and *tuple[...]. It must not drop the Unpack part.
  • gh-100573: Fix a Windows asyncio bug with named pipes where a client doing os.stat() on the pipe would cause an error in the server that disabled serving future requests.
  • gh-100805: Modify random.choice() implementation to once again work with NumPy arrays.
  • gh-90104: Avoid RecursionError on repr if a dataclass field definition has a cyclic reference.
  • gh-100750: pass encoding kwarg to subprocess in platform
  • gh-100689: Fix crash in pyexpat by statically allocating PyExpat_CAPI capsule.
  • gh-100740: Fix unittest.mock.Mock not respecting the spec for attribute names prefixed with assert.
  • gh-86508: Fix asyncio.open_connection() to skip binding to local addresses of different family. Patch by Kumar Aditya.
  • gh-100287: Fix the interaction of unittest.mock.seal() with unittest.mock.AsyncMock.
  • gh-100474: http.server now checks that an index page is actually a regular file before trying to serve it. This avoids issues with directories named index.html.
  • gh-100160: Remove any deprecation warnings in asyncio.get_event_loop(). They are deferred to Python 3.12.
  • gh-96290: Fix handling of partial and invalid UNC drives in ntpath.splitdrive(), and in ntpath.normpath() on non-Windows systems. Paths such as '\server' and '\' are now considered by splitdrive() to contain only a drive, and consequently are not modified by normpath() on non-Windows systems. The behaviour of normpath() on Windows systems is unaffected, as native OS APIs are used. Patch by Eryk Sun, with contributions by Barney Gale.
  • gh-78878: Fix crash when creating an instance of _ctypes.CField.
  • gh-99952: Fix a reference undercounting issue in ctypes.Structure with from_param() results larger than a C pointer.
  • gh-100133: Fix regression in asyncio where a subprocess would sometimes lose data received from pipe.
  • gh-100098: Fix tuple subclasses being cast to tuple when used as enum values.
  • gh-98778: Update HTTPError to be initialized properly, even if the fp is None. Patch by Dong-hee Na.
  • gh-83035: Fix inspect.getsource() handling of decorator calls with nested parentheses.
  • gh-99576: Fix .save() method for LWPCookieJar and MozillaCookieJar: saved file was not truncated on repeated save.
  • gh-99433: Fix doctest failure on types.MethodWrapperType in modules.
  • gh-99240: Fix double-free bug in Argument Clinic str_converter by extracting memory clean up to a new post_parsing section.
  • gh-64490: Fix refcount error when arguments are packed to tuple in Argument Clinic.
  • gh-85267: Several improvements to inspect.signature()'s handling of __text_signature. - Fixes a case where inspect.signature() dropped parameters - Fixes a case where inspect.signature() raised tokenize.TokenError - Allows inspect.signature() to understand defaults involving binary operations of constants - inspect.signature() is documented as only raising TypeError or ValueError, but sometimes raised RuntimeError. These cases now raise ValueError - Removed a dead code path
  • gh-95882: Fix a 3.11 regression in asynccontextmanager(), which caused it to propagate exceptions with incorrect tracebacks and fix a 3.11 regression in contextmanager(), which caused it to propagate exceptions with incorrect tracebacks for StopIteration.
  • bpo-44817: Ignore WinError 53 (ERROR_BAD_NETPATH), 65 (ERROR_NETWORK_ACCESS_DENIED) and 161 (ERROR_BAD_PATHNAME) when using ntpath.realpath().
  • bpo-40447: Accept os.PathLike (such as pathlib.Path) in the stripdir arguments of compileall.compile_file() and compileall.compile_dir().
  • bpo-36880: Fix a reference counting issue when a ctypes callback with return type py_object returns None, which could cause crashes.

Documentation

  • gh-100616: Document existing attr parameter to curses.window.vline() function in curses.
  • gh-100472: Remove claim in documentation that the stripdir, prependdir and limit_sl_dest parameters of compileall.compile_dir() and compileall.compile_file() could be bytes.
  • gh-99931: Use sphinxext-opengraph to generate OpenGraph metadata.
  • Tests
  • gh-101334: test_tarfile has been updated to pass when run as a high UID.
  • gh-100454: Start running SSL tests with OpenSSL 3.1.0-beta1.
  • gh-96002: Add functional test for Argument Clinic.
  • Build
  • gh-101522: Allow overriding Windows dependencies versions and paths using MSBuild properties.
  • Windows
  • gh-101543: Ensure the install path in the registry is only used when the standard library hasn't been located in any other way.
  • gh-101467: The py.exe launcher now correctly filters when only a single runtime is installed. It also correctly handles prefix matches on tags so that -3.1 does not match 3.11, but would still match 3.1-32.
  • gh-101135: Restore ability to launch older 32-bit versions from the py.exe launcher when both 32-bit and 64-bit installs of the same version are available.
  • gh-82052: Fixed an issue where writing more than 32K of Unicode output to the console screen in one go can result in mojibake.
  • gh-100320: Ensures the PythonPath registry key from an install is used when launching from a different copy of Python that relies on an existing install to provide a copy of its modules and standard library.
  • gh-100247: Restores support for the py.exe launcher finding shebang commands in its configuration file using the full command name.
  • gh-100180: Update Windows installer to OpenSSL 1.1.1s
  • bpo-43984: winreg.SetValueEx() now leaves the target value untouched in the case of conversion errors. Previously, -1 would be written in case of such errors.

macOS

  • gh-100180: Update macOS installer to OpenSSL 1.1.1s

Tools/Demos

  • bpo-45256: Fix a bug that caused an AttributeError to be raised in python-gdb.py when py-locals is used without a frame.
  • gh-100342: Add missing NULL check for possible allocation failure in *args parsing in Argument Clinic.
  • gh-64490: Argument Clinic varargs bugfixes
  • Fix out-of-bounds error in _PyArg_UnpackKeywordsWithVararg().
  • Fix incorrect check which allowed more than one varargs in clinic.py.
  • Fix miscalculation of noptargs in generated code.
  • Do not generate noptargs when there is a vararg argument and no optional argument.

C API

  • gh-99240: In argument parsing, after deallocating newly allocated memory, reset its pointer to NULL.

Previous release notes

Python 3.11.1 is the newest major release of the Python programming language, and it contains many new features and optimizations.

Major new features of the 3.11 series, compared to 3.10

Some of the new major new features and changes in Python 3.11 are:

General changes

  • PEP 657 – Include Fine-Grained Error Locations in Tracebacks
  • PEP 654 – Exception Groups and except*
  • PEP 680 – tomllib: Support for Parsing TOML in the Standard Library
  • gh-90908 – Introduce task groups to asyncio
  • gh-34627 – Atomic grouping ((?>...)) and possessive quantifiers (*+, ++, ?+, {m,n}+) are now supported in regular expressions.

The Faster CPython Project is already yielding some exciting results. Python 3.11 is up to 10-60% faster than Python 3.10. On average, we measured a 1.22x speedup on the standard benchmark suite. See Faster CPython for details.

Typing and typing language changes

  • PEP 673 – Self Type
  • PEP 646 – Variadic Generics
  • PEP 675 – Arbitrary Literal String Type
  • PEP 655 – Marking individual TypedDict items as required or potentially-missing
  • PEP 681 – Data Class Transforms