Abhay Prajapati
Abhay Prajapati

Reputation: 9

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

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

Upvotes: 1

Views: 530

Answers (2)

Wawa
Wawa

Reputation: 341

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

Upvotes: 1

abderahmen Gasmi
abderahmen Gasmi

Reputation: 11

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

Upvotes: 1

Related Questions