3 ms·
sure if you use malloc directly in your cython code, you're out on a limb. That's not how simple use of cython goes. You can apply cython to Python code direc
by zzzeek 3y ago
sure if you use malloc directly in your cython code, you're out on a limb. That's not how simple use of cython goes. You can apply cython to Python code directly as a code inliner and there's little to no risk of C-style issues being introduced.
"two compiler passes being a problem" again this is if you are writing big tracts of C code in your cython; not how it's normally used.
"No standardized package or build system for dependencies" / "all the incentives push you to write everything from scratch in Cython, rather than reuse preexisting libraries." - I dont really understand this part, is this just a general C/C++ does not encourage the use of other native dependencies? We are using Cython to write Python code that is more optimized than plain Python. our dependencies are normally going to be other Python dependencies. If our Cython is to wrap some well known native library, then that has to be installed also when the Python wheel is installed, and that doesnt change if your Python wheel was built from Rust source or C/C++ source.
We use Cython in SQLAlchemy to tremendous effect and excellent integration with existing Python code, including being able to fall back to pure Python (so that our source install runs even if you dont have a compiler or are using Pypy), and we've had zero user issues /bugs / anything. We will consider the Rust tools once they've had several years of maturity and widespread use under their belts (meaning, they'd have to meet or surpass cython's popularity), otherwise we aren't going to hoist that on our userbase anytime soon.
- cb321 3y agoIndeed. It is pretty easy to just write some Cython routine against the data pointer & range lifted out of some NumPy array and then still let Python do all the memory management for you. I think Cython is great for just speeding up profiling-revealed hot spots. And `cython --annotate` is even a nice helper along that path. { In fact, I think gcc should have a similar system one could integrate so that you can click-expand the Python to get the C and then click again the C to get the assembly. :-) } It really makes Python more like the gradually typed system Common Lisp always was. In fact, there was talk back in the very early noughties of bundling a precursor of Cython with the Python interpreter itself. I was always a bit disappointed that didn't go very far. Ah well.