6 ms·
A high-performance, zero-overhead, extensible Python compiler using LLVM
- actionfromafar 2y agoI 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/ https://github.com/shedskin/shedskin/
- crorella 2y agoI looks like codon has less restrictions when compared to shed skin.
- actionfromafar 2y agoI suppose that's right, I don't think shedskin can call numpy yet, for instance. On the other hand it seems easier to put shedskin on an embedded device, for instance.
- Lucasoato 2y ago> 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.
- troymc 2y agoThe license is the "Business Source License 1.1" [1]. The Business Source License (BSL) 1.1 is a software license created by MariaDB Corporation. It's designed as a middle ground between fully open-source licenses and traditional proprietary software licenses. It's kind of neat because it's a parameteric license, in that you can change some parameters while leaving the text of the license unchanged. For codon, the "Change Date" is 2028-03-01 and the "Change License" is "Apache License, Version 2.0", meaning that the license will change to Apache2 in March of 2028. Until then, I guess you need to make a deal with Exaloop to use codon in production. [1] https://github.com/exaloop/codon?tab=License-1-ov-file#readme https://github.com/exaloop/codon?tab=License-1-ov-file#readm...
- axit 2y agoFrom what I've seen is the "Change Date" is usually updated so you always have a few years older software as Apache License and the latest software as BSL
- actionfromafar 2y agoJust to make it clear - the cutoff date on previously released software remains the same. So if you download it now and wait a few years, your software will have matured into its final form, the Apache 2 license.
- troymc 2y agoThat make sense. Thanks for clarifying.
- jitl 2y agoWhat’s the difference between this and Cython? I think another comment already asks about shedskin.
- deleted 2y ago[deleted]
- rich_sasha 2y agoCython relies heavily on the Python runtime. You cannot, for example, make a standalone binary with it. A lot of unoptimized Cython binary is just Python wrapped in C. From a quick glance this seems to genuinely translate into native execution.
- edscho 2y agoYou absolutely can create a standalone binary with Cython: see the `--embed` option [1]. [1] https://cython.readthedocs.io/en/stable/src/tutorial/embedding.html https://cython.readthedocs.io/en/stable/src/tutorial/embeddi...
- veber-alex 2y agoWhat'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/ https://exaloop.io/benchmarks/
- sdmike1 2y agoThe benchmark page looks to be broken, the JS console is showing some 404'd JS libs and a bad function call.
- pizlonator 2y agoAlso those are some bullshit benchmarks. It’s not surprising that you can make a static compiler that makes tiny little programs written in a dynamic language into fast executables. The hard part is making that scale to >=10,000 LoC programs. I dunno which static reasoning approaches codon uses, but all the ones I’m familiar with fall apart when you try to scale to large code. That’s why JS benchmarking focused on larger and larger programs over time. Even the small programs that JS JIT writers use tend to have a lot of subtle idioms that break static reasoning, to model what happens in larger programs. If you want to get in the business of making dynamic languages fast then the best advice I can give you is don’t use any of the benchmarks that these folks cite for your perf tuning. If you really do have to start with small programs then something like Richards or deltablue are ok, but you’ll want to diversify to larger programs if you really want to keep it real. (Source: I was a combatant in the JS perf wars for a decade as a webkitten.)
- big-chungus4 2y agoso, 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
- w10-1 2y agoUnclear 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 https://news.ycombinator.com/item?id=41570708 - [2] GraalVM Python site https://www.graalvm.org/python/ https://www.graalvm.org/python/ - [3] HN Dec 2022 https://news.ycombinator.com/item?id=33908576 https://news.ycombinator.com/item?id=33908576
- Sparkenstein 2y agoBiggest problem at the moment is async support, I guess https://github.com/exaloop/codon/issues/71 https://github.com/exaloop/codon/issues/71
- codethief 2y agoReminds me of these two projects which were presented at EuroPython 2024 this summer: https://ep2024.europython.eu/session/spy-static-python-lang-fast-as-c-pythonic-as-python https://ep2024.europython.eu/session/spy-static-python-lang-... https://ep2024.europython.eu/session/how-to-build-a-python-to-c-compiler-out-of-spare-parts-and-why 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.)
- haberman 2y ago> 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-typing 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.
- odo1242 2y agoYeah, it feels closer to something like Cython without the python part.
- quotemstr 2y agoIt's not even a subset. They break foundational contracts of the Python language without technical necessity. For example, > Dictionaries: Codon's dictionary type does not preserve insertion order, unlike Python's as of 3.6. That's a gratuitous break. Nothing about preserving insertion order interferes with compilation, AOT or otherwise. The authors of Codon broke dict ordering because they felt like it, not because they had to. At least Mojo merely claims to be Python-like. Unlike Codon, it doesn't claim to be Python then note in the fine print that it doesn't uphold Python contractual language semantics.
- orf 2y agoTry not to throw around statements like “they broke duct ordering because they felt like it”. Obviously they didn’t do that. There are trade-offs when preserving dictionary ordering.
- actionfromafar 2y agoThe trade-off is a bit of speed.
- timwaagh 2y agoIt'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.
- zamazan4ik 2y agoI hope one day the compiler itself will be optimized even more: https://github.com/exaloop/codon/issues/137 https://github.com/exaloop/codon/issues/137
- jay-barronville 2y agoInstead 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 https://docs.exaloop.io/codon/advanced/gpu [1]: https://www.w3.org/TR/webgpu https://www.w3.org/TR/webgpu [2]: https://wgpu.rs https://wgpu.rs
- MadnessASAP 2y agoWell for better or worse CUDA is the GPU programming API. If you're doing high performance GPU workloads you're almost certainly doing it in CUDA. WebGPU while stating compute is within their design I would imagine is focused on presentation/rendering and probably not on large demanding workloads.
- pjmlp 2y agoBecause WebGPU is a API designed for browsers, targeting hardware designs from 2016.
- ipsum2 2y agoPrevious discussion (2022): https://news.ycombinator.com/item?id=33908576 https://news.ycombinator.com/item?id=33908576
- amelius 2y agoThe 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.
- Myrmornis 2y agoThis should be top comment. If I don't get the ecosystem then I'd just use Rust.
- eigenspace 2y agoIt’s also just simply not python. It’s a separate language with a confusingly close syntax to python, but quite different semantics.
- shikon7 2y agoFrom 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?
- tony-allan 2y agoI would love to see LLVM/WebAssembly as a supported and documented backend!
- GTP 2y agoPeople that landed here may be interested in Mojo [0] as well. [0] https://www.modular.com/mojo https://www.modular.com/mojo
- mgaunard 2y agoaren't there like a dozen of those already? numba, cython, pypy...
- albertzeyer 2y agoThere is also RPython (used by PyPy) (https://rpython.readthedocs.io/ 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.
- xiaodai 2y agoPlease stop trying to make python fast. Move over to Julia already.