Live data from Hacker News

Cython is 20

blog.behnel.de

41–50 of 71 posts

Re: Cython is 20

#41
post #38

Earlier quoted context omitted.

Writing a much faster language runtime for a language that looks quite a bit like Python is easy. The hard problem is writing a faster language runtime that is 100% compatible with all current python programs (and their extensions) out in the world.

But this is not necessary. The python developers just need to specify this fast subset of the language, and let people use to create libraries. Over time, we would have a growing set of libraries written in the fast subset.

People have. See PyPy and Pythran for two examples currently under active development. Instagram has such a project as well that they recently released. I know there have been others. None of them seem to catch on. It seems that most people don't actually want a faster subset of python. They want either all of python or none of python (by switching to another language all together)

Re: Cython is 20

#43

I love Cython. I really feel like it's the right balance of usability and allowing you to do what you want/need. Want to make your code a bit faster? Write Python with type annotations. Want to call a C library? Just import the header, and then use it from a function. Pybind11 is also great, but quite different in aims - I feel like it's more like a project for C++ programmers wanting to expose functionality to Pytho…

Python with type annotations isnt faster using python runtime. But some packages can utilize it for higher performance but most of the time it'll be slower cause you need to parse extra information if you want to reuse it in pure python.

You're thinking of CPython, the standard implementation of Python. Cython is a (barely) separate language that looks a lot like Python but gets compiled to something like C. When you need performance, you can drop down from (C)Python into Cython

Re: Cython is 20

#44
post #41

Earlier quoted context omitted.

But this is not necessary. The python developers just need to specify this fast subset of the language, and let people use to create libraries. Over time, we would have a growing set of libraries written in the fast subset.

People have. See PyPy and Pythran for two examples currently under active development. Instagram has such a project as well that they recently released. I know there have been others. None of them seem to catch on. It seems that most people don't actually want a faster subset of python. They want either all of python or none of python (by switching to another language all together)

I'm not and have never been a game developer, but I think that a decent analogy here might be how many game studios write the core engine in C++, and then do a lot of the high level game logic and scripting in an interpreted language such as Lua or their own dialect of lisp.

I would guess that there's a clear separation of responsibilities, and each of the two languages is very well-suited to what it's being used for. There's not really a whole lot of anxiety about getting Lua (or whatever) to pull out all the stops you see in a compiler like SBCL or interpreter like V8, because these communities were never looking for a single language that could cover all uses cases in the first place. To steal an analogy I used the other day from myself, I'm guessing they don't want a spork all that badly because they're plenty happy with using a fork and a spoon.

That's how the community of people doing scientific computing and suchlike in Python tends to feel about things, too.

Re: Cython is 20

#45

I love Cython. I really feel like it's the right balance of usability and allowing you to do what you want/need. Want to make your code a bit faster? Write Python with type annotations. Want to call a C library? Just import the header, and then use it from a function. Pybind11 is also great, but quite different in aims - I feel like it's more like a project for C++ programmers wanting to expose functionality to Pytho…

Python with type annotations isnt faster using python runtime. But some packages can utilize it for higher performance but most of the time it'll be slower cause you need to parse extra information if you want to reuse it in pure python.

Mb im blind ofc Cython would be faster :P

Re: Cython is 20

#46
cython --annotate is an ok way to learn the whys & whereabouts of the rather hairy CPython API. That gives you an HTML page you can click on to expand your python code into equivalent-ish C API calls. Darker yellow means more calls, too. So, it's not a terrible start to do static analysis to guide optimization, but a combination score (with a run-time profile) would be even better.

I believe there was a time very early on (like 2003) when there was discussion about maybe including Pyrex in CPython proper to get a more Common-Lisp like gradually typed system. (I mostly recall some comment of Greg's along the lines of being intimidated by such. I'm not sure how seriously the idea was entertained by PyCore.)

Re: Cython is 20

#47
post #32

Earlier quoted context omitted.

Julia is great if you can afford to spend 5 minutes sitting around for your session to load, but most people have things to do.

How many times a day are you starting sessions?

I work in Python, but I might restart, create new sessions, etc anywhere between 1-100 times a day depending on what I am doing.

Re: Cython is 20

#48
post #30

Earlier quoted context omitted.

Julia is great if you can afford to spend 5 minutes sitting around for your session to load, but most people have things to do.

Julia has its own heap of issues, but five minutes is a load of bull: > time julia -e 'using Plots; plot(rand(10, 5), rand(10))' ________________________________________________________ Executed in 5.77 secs fish external usr time 5.74 secs 214.00 micros 5.74 secs sys time 0.57 secs 0.00 micros 0.57 secs This is also on a fairly old version at that: > julia -v julia version 1.6.3 Regardless, this conversation was to…

Also, if you make a sysimage, startup time can be reduced to <1s. This doesn't get a ton of publicity because many of the more active Julia devs are developing lots of packages and/or developing Julia which makes this less applicable to them, but if you are waiting more than a few seconds to load packages that you aren't a developer of, sysimages are a wonderful quality of life improvement.

Re: Cython is 20

#49

I would recommend considering using NanoBind, the follow up of PyBind11 by the same author (Wensel Jakob), and move as much performance critical code to C or C++. https://github.com/wjakob/nanobind If you really care about performance called from Python, consider something like NVIDIA Warp (Preview). Warp jits and runs your code on CUDA or CPU. Although Warp targets physics simulation, geometry processing, and proced…

Or alternatively, PyO3 if you use Rust instead of C++: https://github.com/PyO3/pyo3
Post reply on HN