power of Python is in ecosystem of libraries, not only Python syntax. Without the ecosystem of libraries, I am afraid use cases for Codon will be very very limited. Because Python developers (just like Node) got used to thinking: Need to do X? Lets see if I can pip install library that does it. Ultimately, python is like super flexible glue between ecosystem of libraries that lets anyone build and prototype high qual…
Codon: A high-performance Python-like compiler using LLVM
141–150 of 184 posts
Re: Codon: A high-performance Python-like compiler using LLVM
#142Just out of curiosity: Why is it possible to compile Common Lisp Code (or Scheme, or Clojure) to high-performance native or jit-compiled code, but not Python? It is said that "Python is too dynamic", but is not everything in Lisp dynamic, too? And none of these languages is less powerful than Lisp, lack Unicode support, or whatever, so this can't be the reason.
It is possible to JIT compile Python just fine. There are projects like PyPy that have been doing this for a long time [1]. The reason these alternative projects never take off is because many of Python's most used libraries are written against CPython's C API. This API is giant, and exposes all of the nitty gritty implementation details of the CPython interpreter. As a result, changing anything significant about the…
So one thing of golang that is nice is that go 1.19 compiler will compile go 1.1 just fine, and people can iterate from 1.1 to 1.19 in their own time -- or not if they choose not to. It would not be that hard for golang v2 to continue to allow similar compilation of old code.
Re: Codon: A high-performance Python-like compiler using LLVM
#143Earlier quoted context omitted.
Don't have anything significant, but giving this a quick test with some of my advent of code solutions I found it to be quite a bit slower: time python day_2.py ________________________________________________________ Executed in 57.25 millis fish external usr time 25.02 millis 52.00 micros 24.97 millis sys time 25.01 millis 601.00 micros 24.41 millis time codon run -release day_2.py _________________________________…
I would guess the bulk of the time is being spent in compilation. You might try "codon build -release day_2.py" then "time ./day_2" to measure just runtime.
time python day_2.py
________________________________________________________
Executed in 51.26 millis fish external
usr time 23.38 millis 48.00 micros 23.33 millis
sys time 21.88 millis 617.00 micros 21.26 millis
time day_2
________________________________________________________
Executed in 227.06 millis fish external
usr time 8.17 millis 70.00 micros 8.10 millis
sys time 6.69 millis 708.00 micros 5.98 millis
time python day_8.py
________________________________________________________
Executed in 53.63 millis fish external
usr time 22.11 millis 51.00 micros 22.06 millis
sys time 24.63 millis 714.00 micros 23.91 millis
time day_8
________________________________________________________
Executed in 115.89 millis fish external
usr time 5.83 millis 92.00 micros 5.74 millis
sys time 4.59 millis 856.00 micros 3.73 millis
Now codon is much faster than Python.Re: Codon: A high-performance Python-like compiler using LLVM
#144Anybody claiming it's almost Python is kidding themselves. This compiler needs to do static type checking. This is inherently impossible in Python. Not just because of some obscure corner cases that nobody uses. It's baked into the language itself. Reality-check: Why do you think type hints and type checkers like mypy and pyright take such a long time to get going and even they are not there yet? If this was all so e…
I mean... if you had a 'compiler; for python that looked at my code at runtime- including imports- and all my current input and.... given the data types it sees and nothing more, do type-inference and recompilation down to LLVM and then to my machine code, while taking things that were already calling compiled modules (like numpy) and keeping them separate subroutines and thus only operating on the 'slow' parts of my code... with the speedups therein.. I'd be sold.
Of course, I think I basically just described Julia.
Re: Codon: A high-performance Python-like compiler using LLVM
#145Anybody claiming it's almost Python is kidding themselves. This compiler needs to do static type checking. This is inherently impossible in Python. Not just because of some obscure corner cases that nobody uses. It's baked into the language itself. Reality-check: Why do you think type hints and type checkers like mypy and pyright take such a long time to get going and even they are not there yet? If this was all so e…
If I can write (mostly) python code and get it to run on my GPU they can oversell this all they want. I have a couple of projects I’ve been wanting to tackle but put off because I like python but it wouldn’t be a very good fit due to performance reasons. Now I get a whole new herd of yaks to shave. Plus, extensible compiler? Who doesn’t want linq in python?
Re: Codon: A high-performance Python-like compiler using LLVM
#146Just out of curiosity: Why is it possible to compile Common Lisp Code (or Scheme, or Clojure) to high-performance native or jit-compiled code, but not Python? It is said that "Python is too dynamic", but is not everything in Lisp dynamic, too? And none of these languages is less powerful than Lisp, lack Unicode support, or whatever, so this can't be the reason.
For example if you write `l.sort()` where l is a list, we can make it very fast to figure out that you are calling the list_sort() C function. Unfortunately that function is quite slow because every comparison uses a dynamic multiple-dispatch resolution mechanism in order to implement Python semantics.
Re: Codon: A high-performance Python-like compiler using LLVM
#147Earlier quoted context omitted.
In 25 years you’ve never once created a list with more than one type of object in it?
I have also been using python a long time and i honestly can’t remember a time i used mixed type list.
Re: Codon: A high-performance Python-like compiler using LLVM
#148Earlier quoted context omitted.
I got a massive jump in performance when moving from Python 3.8 to 3.10 (over some function call optimizations I think, based on the project). And 3.11 got even better (up to 50% faster on special cases, and 10~15% on average) with respect to 3.10. Python 3.12 is already getting even more speedups and a there's a lot more down the road[0]. But Python core developers value keeping "not breaking anyones code" (Python 3…
I got performance regression going from 3.10 to 3.11 https://ltworf.github.io/typedload/performance.html
If it's not too big, you might as well just leave things as they are and wait for 3.12 to see what changes then. Apparently the changes will be bigger, so it could be be much better than 3.11 (without being much worse, hopefully!).
Re: Codon: A high-performance Python-like compiler using LLVM
#149Earlier quoted context omitted.
I got a massive jump in performance when moving from Python 3.8 to 3.10 (over some function call optimizations I think, based on the project). And 3.11 got even better (up to 50% faster on special cases, and 10~15% on average) with respect to 3.10. Python 3.12 is already getting even more speedups and a there's a lot more down the road[0]. But Python core developers value keeping "not breaking anyones code" (Python 3…
Interesting. What is the status of the GIL these days?
Re: Codon: A high-performance Python-like compiler using LLVM
#150Just out of curiosity: Why is it possible to compile Common Lisp Code (or Scheme, or Clojure) to high-performance native or jit-compiled code, but not Python? It is said that "Python is too dynamic", but is not everything in Lisp dynamic, too? And none of these languages is less powerful than Lisp, lack Unicode support, or whatever, so this can't be the reason.