Serdar Yegulalp
Senior Writer
Updated

The best new features and fixes in Python 3.13

A new JIT compiler, the first no-GIL edition of Python, better errors and typing enhancement, and the removal of dead batteries are all part of Python 3.13.

The best, applause, celebrate
Credit: Party people studio/Shutterstock

Python 3.13ย has just been released. This article presents a rundown of the most significant new features in Python 3.13 and what they mean for Python developers.

Major new features in Python 3.13

Hereโ€™s a rundown of the biggest new features in Python 3.13:

  • The experimental JIT
  • The no-GIL build of Python
  • A new REPL
  • Improved error messages
  • Enhancements to Python types
  • No more โ€œdead batteriesโ€

The experimental JIT

Python 3.11 introduced theย Specializing Adaptive Interpreter. When the interpreter detects that some operations predictably involve the same types, those operations are โ€œspecialized.โ€ The generic bytecode used for that code is swapped with bytecode specific to working with those types, which delivers speed boosts of anywhere from 10% to 25% for those regions of the code.

Python 3.12 brought more specializations and other refinements to the interpreter. Now, Python 3.13 addsย new elementsย to the JIT that generate actual machine code at runtime, instead of just specialized bytecode. The resulting speedup isnโ€™t much just yetโ€”maybe 5%โ€”but it paves the way for future optimizations that werenโ€™t previously possible.

Right now, the JIT is considered experimentalโ€”itโ€™s not enabled by default, and can only be enabled by compiling CPython from source with certain flags. If in time it yields a significant performance boost (5% or more), and doesnโ€™t impose a large management burden on the CPython team or Pythonโ€™s users as a whole, itโ€™ll become a fully supported build option. Whether or not it will be enabled for official releases will still be up to the managers for a given platformโ€™s CPython builds.

Pythonโ€™s release cycle

Theย Python programming languageย releases new versions yearly, with a feature-locked beta release in the first half of the year and the final release toward the end of the year. Developers are encouraged to try out this latest version on non-production code, both to verify that it works with your programs and to get an idea of whether your code will benefit from the new feature sets and performance enhancements in this latest version.

The no-GIL โ€˜free-threadedโ€™ build of Python

The official term forย possible future versions of CPython with no Global Interpreter Lockย (or GIL) is โ€œfree-threaded CPython.โ€ This CPython build allows threads to run fully in parallel, without mediation from the GIL. To that end, CPU-bound work that once only benefited from being run in multipleย processesย can run in multipleย threads.

Free-threaded CPython is also experimental. Itโ€™s not enabled by default in the shipped builds, so it needs to be enabled at compile time. If future work with the free-threaded builds shows it can improve multithreaded performance without impacting single-threaded performance, itโ€™ll be promoted to a fully supported option. In time, the free-threaded build of CPython may become the default.

A new REPL

The REPL, or interactive interpreter, launches when you run Python from the command line without executing a program. Python 3.13โ€™s REPL has enhancements to make it less stodgy and more like an actual editor:

  • Output to the console now has color enabled by default. This enhancement provides richer error messages, for instance.
  • You can open the interactiveย pydocย help browser by pressing F1.
  • You can browse the command-line history with F2.
  • You can paste large blocks of code more easily by pressing F3 to enable a special block-paste mode.
  • You can just typeย exitย orย quit, instead ofย exit()ย orย quit(), to leave the REPL.

Note that these improvements currently are only available on Linux and macOS. They are not available on Microsoft Windows, not even when using the new Windows Terminal console host.

Improved error messages

Error traces in Python have become more precise and detailed over the last two releases. Python 3.13 continues on that trajectory.

  • If you attempt to import something that has the same name as the module currently in context, Python will provide a detailed error to that effect, and encourage you to rename the current module. This is a very frequent source of bugsโ€”and not only for beginners. Itโ€™s a common mistake to name a module after something in the standard library.
  • If you pass a function an incorrect keyword argument, the error will suggest some possible correct arguments, based on whatโ€™s available in the function being called.
  • Where supported, error messages nowย use color in tracebacksย to make them easier to read.

Enhancements to Python types

Pythonโ€™s type hinting system has expanded in functionality and utility with each new version. Version 3.13 adds three big new changes.

Type parameters support defaults

typing.TypeVar,ย typing.ParamSpec, andย typing.TypeVarTupleย all let youย define defaults to be usedย if no type is explicitly specified. For instance:


T = TypeVar("T", default=str)

In cases whereย Tย is not explicitly defined when used,ย strย is assumed to be the default.

typing.TypeIs for type narrowing

In Python generally, we can useย isinstance()ย to make decisions based on whether or not something is a given type.ย typing.TypeIsย lets us do the same thing in Pythonโ€™s type hinting mechanisms. This way, functions used to validate whether or not something is a given type can be annotated to show they perform that narrowing behavior, rather than just a return type. This is useful as a way to add precise type checker coverage to those functions.

typing.ReadOnly for read-only annotation

Theย typing.TypedDictย type was created to annotate dictionaries with fixed types for the values associated with certain keys.ย typing.Readonlyย lets youย annotate specific values in a TypedDict as read-only. An example is a list that you can only append to or pop from, not replace with a string or other type.

No more โ€˜dead batteriesโ€™

Python 3.11 identified a slew of Python standard library modules that wereย obsolete and no longer being maintained. The plan was to mark them as deprecated for 3.11 and 3.12, and then remove them entirely in Python 3.13. As of now, those โ€œdead batteriesโ€ (as theyโ€™ve been called) are now permanently removed.ย Many of the removed modules can be replacedย with third-party modules, or their functionality can be emulated using other standard library components.

Users can expectย more deprecations to comeย over the next three versions of Python, as well. Most are methods for various standard library components that are rarely used or undocumented.

Serdar Yegulalp

Serdar Yegulalp is a senior writer at InfoWorld. A veteran technology journalist, Serdar has been writing about computers, operating systems, databases, programming, and other information technology topics for 30 years. Before joining InfoWorld in 2013, Serdar wrote for Windows Magazine, InformationWeek, Byte, and a slew of other publications. At InfoWorld, Serdar has covered software development, devops, containerization, machine learning, and artificial intelligence, winning several B2B journalism awards including a 2024 Neal Award and a 2025 Azbee Award for best instructional content and best how-to article, respectively. He currently focuses on software development tools and technologies and major programming languages including Python, Rust, Go, Zig, and Wasm. Tune into his weekly Dev with Serdar videos for programming tips and techniques and close looks at programming libraries and tools.

More from this author