|
|
|
|
|
by isofruit
1415 days ago
|
|
I do not have any experience with C++ and thus none about its python interop, which makes it hard for me to compare it to nim's python interop which I do have some experience with. Given that, I'm curious what bits of C++/python interop are easier. I'm mostly asking because my experience of nim-python interop consisted of:
Compile nim module with nimpy imported.
Put compiled nim module somewhere where your python can find it.
write `import <Name_of_module>` in the python file
Done, you now have access to the exported functions and symbols defined in the nim module. Is it that C++ wouldn't need any additional imports to make it work that makes it more seamless? |
|
In C++, you'd write your C++ code as if you don't care about Python. Then, you add the "glue" code, which tells C++ how to convert objects to and from Python (there's more options than that but let's leave it here). That, plus a lot of boilerplate. Then, in effect, you can pass objects back and forth between Python and C++, create objects in C++, return them to Python, pass them back to more C++ functions, and so on.
I haven't used Nim+Python; but looking at Nimpy documentation, it looks like, for example, to export a class from Nim to Python, it needs to inherit from a special underlying class. You can't just take a class and make it available in Python. And even then, can you pass that back to Nim to call a function with?
Maybe yes, and if so, that bumps Nim higher up my priority list.