Python 3.13 Gets a JIT

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • luajit-remake

    An ongoing attempt to re-engineer LuaJIT from scratch

  • It's really cool that Haoran Xu copy-and-patch technique is catching on, I remember discovering it through his blog posts on applying these techniques to his own LuaJIT remake project[0][1] (and I probably found those through a post here). I highly recommend them if you're into that sort of thing, BTW. They're incredible deep dives, but he uses the details-element to keep the metaphorical descents into Mariana Trench optional so it doesn't get too overwhelming.

    I even had the privilege of congratulating him the 1000th star of the GH repo[2], where he reassured me and others that he's still working on it despite the long pause after the last blog post, and that this mainly has to do with behind-the-scenes rewrites that make no sense to publish in part.

    [0] https://sillycross.github.io/2022/11/22/2022-11-22/

    [1] https://sillycross.github.io/2023/05/12/2023-05-12/

    [2] https://github.com/luajit-remake/luajit-remake/issues/11

  • mypy

    Optional static typing for Python

  • There is already an AOT compiler for Python: Nuitka[0]. But I don't think it's much faster.

    And then there is mypyc[1] which uses mypy's static type annotations but is only slightly faster.

    And various other compilers like Numba and Cython that work with specialized dialects of Python to achieve better results, but then it's not quite Python anymore.

    [0] https://nuitka.net/

    [1] https://github.com/python/mypy/tree/master/mypyc

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • Nuitka

    Nuitka is a Python compiler written in Python. It's fully compatible with Python 2.6, 2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, and 3.11. You feed it your Python app, it does a lot of clever things, and spits out an executable or extension module.

  • There is already an AOT compiler for Python: Nuitka[0]. But I don't think it's much faster.

    And then there is mypyc[1] which uses mypy's static type annotations but is only slightly faster.

    And various other compilers like Numba and Cython that work with specialized dialects of Python to achieve better results, but then it's not quite Python anymore.

    [0] https://nuitka.net/

    [1] https://github.com/python/mypy/tree/master/mypyc

  • plb2

    A programming language benchmark

  • I wouldn't be so enthusiastic. Look at other languages that have JIT now: Ruby and PHP. After years of efforts, they are still an order of magnitude slower than V8 and even PyPy [1]. It seems to me that you need to design a JIT implementation from ground up to get good performance – V8, Dart, LuaJIT and PyPy are like this; if you start with a pure interpreter, it may be difficult to speed it up later.

    [1] https://github.com/attractivechaos/plb2

  • Iron python

    Implementation of the Python programming language for .NET Framework; built on top of the Dynamic Language Runtime (DLR).

  • If you're interested in learning more about the challenges and tradeoffs, both Jython (https://www.jython.org/) and IronPython (https://ironpython.net/) have been around for a long time and there's a lot of reading material on that subject.

  • tarantool

    Get your data in RAM. Get compute close to data. Enjoy the performance.

  • The article describes that the new JIT is a "copy-and-patch JIT" (I've previously heard this called a "splat JIT"). This is a relatively simple JIT architecture where you have essentially pre-compiled blobs of machine code for each interpreter instruction that you patch immediate arguments into by copying over them.

    I once wrote an article about very simple JITs, and the first example in my article uses this style: https://blog.reverberate.org/2012/12/hello-jit-world-joy-of-...

    I take some issue with this statement, made later in the article, about the pros/cons vs a "full" JIT:

    > The big downside with a “full” JIT is that the process of compiling once into IL and then again into machine code is slow. Not only is it slow, but it is memory intensive.

    I used to think this was true also, because my main exposure to JITs was the JVM, which is indeed memory-intensive and slow.

    But then in 2013, a miraculous thing happened. LuaJIT 2.0 was released, and it was incredibly fast to JIT compile.

    LuaJIT is undoubtedly a "full" JIT compiler. It uses SSA form and performs many optimizations (https://github.com/tarantool/tarantool/wiki/LuaJIT-Optimizat...). And yet feels no more heavyweight than an interpreter when you run it. It does not have any noticeable warm up time, unlike the JVM.

    Ever since then, I've rejected the idea that JIT compilers have to be slow and heavyweight.

  • Nuitka-Action

    Action to build with Nuitka on GitHub in your workflows

  • Have you taken a look at Nuitka with GitHub actions for cross compilation? https://github.com/Nuitka/Nuitka-Action

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • CPython

    The Python programming language

  • The PR message with a riff off the Night Before Christmas is gold.

    https://github.com/python/cpython/pull/113465

  • LuaJIT

    Mirror of the LuaJIT git repository

  • The commit history looks pretty active...

    https://github.com/LuaJIT/LuaJIT/commits/v2.1/

  • Pyjion

    Pyjion - A JIT for Python based upon CoreCLR (by tonybaloney)

  • It exists, was created by microsoft employees, and is referenced in the article: https://www.trypyjion.com/

  • Paste JSON as Code • quicktype

    Xcode extension to paste JSON as Swift, Objective-C, and more

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts