from Hacker News

A high-performance, zero-overhead, extensible Python compiler using LLVM

by wspeirs on 9/18/24, 2:44 PM with 93 comments

  • by haberman on 9/18/24, 7:04 PM

    > Non-goals: Drop-in replacement for CPython: Codon is not a drop-in replacement for CPython. There are some aspects of Python that are not suitable for static compilation — we don't support these in Codon.

    This is targeting a Python subset, not Python itself.

    For example, something as simple as this will not compile, because lists cannot mix types in Codon (https://docs.exaloop.io/codon/language/collections#strong-ty...):

        l = [1, 's']
    
    It's confusing to call this a "Python compiler" when the constraints it imposes pretty fundamentally change the nature of the language.
  • by Lucasoato on 9/18/24, 3:56 PM

    > Is Codon free? Codon is and always will be free for non-production use. That means you can use Codon freely for personal, academic, or other non-commercial applications.

    I hope it is released under a truly open-source license in the future; this seems like a promising technology. I'm also wondering how it would match C++ performance if it is still garbage collected.

  • by actionfromafar on 9/18/24, 3:24 PM

    I immediately wonder how it compares to Shedskin¹

    I can say one thing - Shedskin compiles to C++, which was very compelling to me for integrating into existing C++ products. Actually another thing too, Shedskin is Open Source under GPLv3. (Like GCC.)

    1: https://github.com/shedskin/shedskin/

  • by amelius on 9/18/24, 11:06 PM

    The challenge is not just to make Python faster, it's to make Python faster __and__ port the ecosystem of Python modules to your new environment.
  • by veber-alex on 9/18/24, 4:29 PM

    What's up with their benchmarks[1], it just shows benchmark names and I don't see any numbers or graphs. Tried Safari and Chrome.

    [1]: https://exaloop.io/benchmarks/

  • by w10-1 on 9/18/24, 5:25 PM

    Unclear if this has been in the works longer as the graalvm LLVM build of python discussed yesterday[1]. The first HN discussion is from 2022 [3].

    Any relation? Any comparisons?

    Funny I can't find the license for graalvm python in their docs [2]. That could be a differentiator.

    - [1] GraalVM Python on HN https://news.ycombinator.com/item?id=41570708

    - [2] GraalVM Python site https://www.graalvm.org/python/

    - [3] HN Dec 2022 https://news.ycombinator.com/item?id=33908576

  • by codethief on 9/18/24, 6:42 PM

    Reminds me of these two projects which were presented at EuroPython 2024 this summer:

    https://ep2024.europython.eu/session/spy-static-python-lang-...

    https://ep2024.europython.eu/session/how-to-build-a-python-t...

    (The talks were fantastic but they have yet to upload the recordings to YouTube.)

  • by timwaagh on 9/18/24, 8:31 PM

    It's a really expensive piece of software. They do not publish their prices because of it. I don't think it's reasonable to market such products onto your average dev because of it. Anyhow Cython and a bunch of others provide a free and open source alternative.
  • by albertzeyer on 9/19/24, 9:45 PM

    There is also RPython (used by PyPy) (https://rpython.readthedocs.io/), which is a strict subset of Python, allowing for static analysis, specifically for the translation logic needed by PyPy. Thus, I was told that RPython is not really intended as a general purpose language/compiler but only really specifically to implement sth like PyPy.

    But it's anyway maybe an interesting comparison to Codon.

  • by jay-barronville on 9/18/24, 9:54 PM

    Instead of building their GPU support atop CUDA/NVIDIA [0], I’m wondering why they didn’t instead go with WebGPU [1] via something like wgpu [2]. Using wgpu, they could offer cross-platform compatibility across several graphics API’s, covering a wide range of hardware including NVIDIA GeForce and Quadro, AMD Radeon, Intel Iris and Arc, ARM Mali, and Apple’s integrated GPU’s.

    They note the following [0]:

    > The GPU module is under active development. APIs and semantics might change between Codon releases.

    The thing is, based on the current syntax and semantics I see, it’ll almost certainly need to change to support non-NVIDIA devices, so I think it might be a better idea to just go with WebGPU compute pipelines sooner rather than later.

    Just my two pennies…

    [0]: https://docs.exaloop.io/codon/advanced/gpu

    [1]: https://www.w3.org/TR/webgpu

    [2]: https://wgpu.rs

  • by GTP on 9/19/24, 6:29 AM

    People that landed here may be interested in Mojo [0] as well.

    [0] https://www.modular.com/mojo

  • by ipsum2 on 9/18/24, 11:34 PM

  • by big-chungus4 on 9/18/24, 4:48 PM

    so, assuming I don't get integers bigger than int64, and don't use the order of build in dicts, can I just use arbitrary python code and use it with codon? Can I use external libraries? Numpy, PyTorch? Also noticed that it isn't supported on windows
  • by shikon7 on 9/19/24, 1:51 AM

    From the documentation of the differences with Python:

    > Strings: Codon currently uses ASCII strings unlike Python's unicode strings.

    That seems really odd to me. Who would use a framework nowadays that doesn't support unicode?

  • by Sparkenstein on 9/18/24, 5:54 PM

    Biggest problem at the moment is async support, I guess

    https://github.com/exaloop/codon/issues/71

  • by zamazan4ik on 9/18/24, 9:26 PM

    I hope one day the compiler itself will be optimized even more: https://github.com/exaloop/codon/issues/137
  • by tony-allan on 9/19/24, 2:53 AM

    I would love to see LLVM/WebAssembly as a supported and documented backend!
  • by xiaodai on 9/20/24, 10:49 AM

    Please stop trying to make python fast. Move over to Julia already.
  • by jitl on 9/18/24, 4:19 PM

    What’s the difference between this and Cython? I think another comment already asks about shedskin.
  • by mgaunard on 9/19/24, 1:30 PM

    aren't there like a dozen of those already?

    numba, cython, pypy...