(no title)
cgreerrun | 3 years ago
My default philosophy is to use python _until_ you find something that is performance sensitive, and then make a C/C++ extension for the slow bits. Pybind works great for a hybrid Python/C++ codebase (https://pybind11.readthedocs.io/en/stable/).
Then you can develop and prototype much quicker w/ Python but re-write the slow parts in C++.
Definitely more of a judgement call when threading and function call overhead enter the equation, but I've found this hybrid "99% of the time Python, 1% C++ when needed" setup works great. And it's typically easier for me to eventually port mature code to C++/Go/etc once I've fleshed it out in Python and hit all the design snags.
cgreerrun|3 years ago
Pybind offers a lot of functionality, but core "good parts" I've found useful are (a) use a numpy array in Python and pass it to a C++ method to work on, (b) pass your python data structure to pybind and then do work on it in C++ (some copy overhead), and (c) Make a class/struct in C++ and expose it to Python (so no copying overhead and you can create nice cache-aware structs, etc.).
[1] https://github.com/pybind/pybind11/blob/master/tests/test_py...
[2] https://gitlab.unistra.fr/benzerara/pybind11/-/tree/master/e...
synergy20|3 years ago
nijave|3 years ago
I've found cross language bindings to be pretty easy with Python. If you want something with memory management, you can use cgo
synergy20|3 years ago
mlyle|3 years ago
Computers are cheap, and people are expensive.
KptMarchewa|3 years ago
bb88|3 years ago
KptMarchewa|3 years ago
jacobr1|3 years ago