by ngoldbaum on 7/18/23, 8:26 PM with 82 comments
by earthnail on 7/19/23, 11:15 AM
There seem to be a lot of cool things in this. For example, semantics for division, power operator, print, classes, types and subscripting are now identical with Python 3. https://cython.readthedocs.io/en/latest/src/changes.html#imp...
Improved interaction with numpy by moving that part of the code into numpy itself: https://cython.readthedocs.io/en/latest/src/changes.html#int...
Improved support for const and volatile in C, and improved support for C++ expressions like std::move https://cython.readthedocs.io/en/latest/src/changes.html#id6
I love how the changelog also shows the bugfixes and improvements that each of these changes enabled. Hats off to the team behind this release.
by mturk on 7/18/23, 9:10 PM
by navels on 7/18/23, 9:06 PM
by Waterluvian on 7/18/23, 11:08 PM
And then I got to re-learn how very bad Poetry and python dependency management is. I’m trying to update pyyaml to 6.0.1 and Poetry systematically downloaded every single major, minor, patch version of another dependency in trying to find which would fit the version constraints. Took half an hour.
by ggm on 7/19/23, 2:46 AM
I have some humongous (for me) dict lookups I am doing on strings, counting in ints, and if I could 2x or 3x faster without having to recode I'd love it. The Cython web is directed at people willing to recode, I am ultimately willing but I wish there was some low hanging fruit evidence: is this even plausibly going to get faster or is dict() walk cost just "it is what it is" ?
Oddly, it looks like across pickle dump/load I get some improvement. Does pickle restoring consume less memory than raw-made?
by westurner on 7/18/23, 8:59 PM
> Since Cython 3.0.0 started development, CPython 3.8-3.11 were released. All these are supported in Cython, including experimental support for the in-development CPython 3.12
by bippingchip on 7/19/23, 7:09 AM
Having used swig to create Python bindings for C++ code over 10 years ago, what’s the recommended way to do this in 2023? There’s still swig, there’s Cython, pybind11 and a few others. I do know swig and how complicated it can get with footguns abound when things grow more complex.
Is Cython the way to go? How does it hold up to the alternatives? Google search gives many articles on the topic, but many typical SEO optimized low-value, and those that do show a bit of depth, focus on the basic mechanics, not really on things hold up for larger projects…
by itamarst on 7/19/23, 11:13 AM
1. Memory unsafety. It's still C or C++ in the end, the more you shift your code in that direction the easier it is to screw up.
2. Two compiler passes: first Cython->C, then C->machine code. This means some errors only get caught in second pass, when it's much harder to match back to the original code. Extra bad when using C++. Perhaps Cython 3 made this better, but it's a very hard problem to solve.
3. Lack of tooling. IDE support, linting, autoformatting... it's all much less extensive than alternatives.
4. Python only. Polars is written in Rust, so you can use it in Rust and Python, and there's work on JavaScript and R bindings. Large Cython code bases are Python only, which makes them less useful.
Long version: https://pythonspeed.com/articles/cython-limitations/
by zaps on 7/19/23, 12:56 AM
by ilayn on 7/19/23, 11:22 AM
Nevermind the foo broke bar comments here.
by gigatexal on 7/18/23, 11:25 PM