4 ms·
Python's strength is that it's easy to make C libs work in it. That's also why CPython is de facto the only Python implementation and stuff like PyPy never took
by frollogaston 2mo ago
Python's strength is that it's easy to make C libs work in it. That's also why CPython is de facto the only Python implementation and stuff like PyPy never took off.
- AdieuToLogic 2mo ago> Python's strength is that it's easy to make C libs work in it. SWIG[0] makes working with C libraries trivial for over a dozen programming languages; Perl, Python, and Ruby included. 0 - https://www.swig.org/ https://www.swig.org/
- frollogaston 2mo agoThere are reasons all those Py libraries with C code didn't just do it in SWIG.
- AdieuToLogic 2mo ago> There are reasons all those Py libraries with C code didn't just do it in SWIG. And those reasons are?
- frollogaston 1mo agoThe point of SWIG is it works across many langs, but this comes at a cost. The SWIG .i and autogen'd C wrapper are extra layers that can get annoying, particularly during debug. Always hated dealing with SWIG'd libs at work. And Python C modules give easier control over Python specifics.
- AdieuToLogic 1mo agoThere's no doubt that hand-written language adapter libraries are less noisy than those generated by a tool such as SWIG. The thing is, debugging tool-generated adapter code is typically more category-based than individual use-case based. IMHO, both approaches have merit depending on the situation. I lean towards using SWIG until and unless the situation warrants a hand-written solution due to the boilerplate nature of these types of libraries.
- kccqzy 2mo agoYeah and I would say that another important factor is Cython, which compiles Python with minimal modifications to C extensions that can in turn be imported in Python. It really makes it easy to get started in Python and worry about performance of the computation later. (Doesn’t help with concurrency I know but that’s a different story.)
- dismalaf 2mo agoRuby can interface with C (or Odin, or anything that can export C style functions) just as easily.
- hetman 2mo agoI would argue more easily.
- hetman 2mo agoI like Python but this was always actually one of my pain points. The CPython C API is full of foot guns, the API surface is expansive, and writing against it requires a lot of careful care. Anyone who's ever written C modules for both languages would be able to attest how much more pleasant the experience was for Ruby than Python.