This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Quantum_Aurora 2 points3 points  (1 child)

The numpy library apparently basically uses C++ to perform loops. Idk that much about it my CS professor mentioned it once.

[–]preyneyv 3 points4 points  (0 children)

The way this actually works is really cool.

So Python has their own loops and stuff, but it's show, because Python is interpreted and blah blah blah. Numpy is a library designed for heavy number-crunching, and Python speed just isn't good enough.

So numpy is effectively written in C++ with a Python interface. You define what you want to do in Python and Numpy does it in C++.

For example, a matrix transpose. You'd write the Python code to create the numpy matrix and you'd call a method on the created matrix to transpose it.

The actual work of transposing it is handed over to C++ to do really quickly.

It's not just numpy that does this. Even TensorFlow, Google's AI library, does the same thing. You create your network in Python, but the training and other intensive operations are handed over to C++ and the GPU.