Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"migrate your package/program/module painlessly to C"

Do you or anyone on your python using team can use C professionally for things you'll use in production?

I work with python everyday on a team that uses python everyday, and I worked professionally in C++ for a >2 years time, and I still wouldn't trust myself to write a reliable/safe C backend to something.

And using C++ behind python with something like pybind11 is anything but painless on the other end; it requires careful consideration.

Python is "good enough" in nearly all cases, but there are some instances where you sort of hate yourself for using it for the prototype since you're forced to effectively rewrite afterwards.



You should try python-cffi. Using python code as a shared library under C is pretty easy, and calling C from python is pretty easy. The documentation is a bit crappy, but it's alright once you get the hang of it.

I recently used it to prototype a shared library that overrides the `getenv` syscall, with the intent of providing decrypt-on-use environment variables. It's pretty simple, stolen from lua I believe.

https://cffi.readthedocs.io/en/latest/overview.html#embeddin...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: