Pregunta

I'll keep my question short and simple.

Assume I have a python program which calls C++ code from a DLL compiled in C/C++.

-Will the speed/performance of the executing code be preserved?

Assume I have a python program ... has a binding to a C++ library (for example - GTK or Wx).

-Is the speed going to match that of the library as if it was compiled with a C++ program?

Thank you.

¿Fue útil?

Solución

When Python calls into C++ code, the code it executes is the machine code generated by the C++ compiler. You will have some cost at the interface level, as you have to marshal Python types into C++ types and vice versa, but the C++ code itself will run at pretty much the same speed as if it were called from C++; any differences will be due to different locality of dynamically allocated memory due to different memory use patterns (which would cause your C++ code to run at different speeds depending on which C++ application called it as well).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top