logoalt Hacker News

frollogastontoday at 12:42 AM4 repliesview on HN

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.


Replies

hetmantoday at 5:49 AM

I 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.

kccqzytoday at 12:56 AM

Yeah 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.)

AdieuToLogictoday at 12:52 AM

> 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/

show 1 reply
dismalaftoday at 12:56 AM

Ruby can interface with C (or Odin, or anything that can export C style functions) just as easily.

show 1 reply