Home > Blockchain >  if NumPy is written in C then how does it work with python?
if NumPy is written in C then how does it work with python?

Time:07-30

enter image description here NumPy is more the 35% written in other languages how do they work internally?

CodePudding user response:

If you are using Python nowadays the most used implementation of Python is CPython wich is written in C, that mean that the interpreter of your python code is written in C

see here the repository of Python on Github,

Using C when creating python allow us to enlarge the ways of possibility

CodePudding user response:

Python being an interpreted language, code written in it tends to be slow, because the interpreter needs to go through each line of the code being executed

because the performance is everything, modules are written in a lower level language like C which is then compiled to a shared object file. These files can be loaded by the Python interpreter and used like a normal python module. Because these modules are already compiled to machine code, they can be directly executed without going through the interpreter, and thus they are much faster than the equivalent code written in Python.

you can find a lot of modules written in c or c with extension .so

  • Related