Skip to content
Advertisement

Implementing a function in Python vs C

Is there a difference (in terms of execution time) between implementing a function in Python and implementing it in C and then calling it from Python? If so, why?

Advertisement

Answer

Python (at least the “standard” CPython implementation) never actually compiles to native machine code; it compiles to bytecode which is then interpreted. So a C function which is in fact compiled to machine code will run faster; the question is whether it will make a relevant difference. So what’s the actual problem you’re trying to solve?

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement