Hacker News new | ask | show | jobs
by mynameisash 1688 days ago
It doesn't need to / you could theoretically do it in C++. It's just that Python (as with other scripting languages) provides really nice, high-level expressiveness and also has a decent module system. You can write code in the REPL or just write a quick-and-dirty script and test it out without write-compile-run cycles.

NumPy is highly optimized for things like matrix math. You get great speed with the C-level module, and you drive it with really simple Python code. So you want to multiply two matrices? The code literally looks no different than multiplying two scalars. That's Python's superpower.

I haven't written C++ in nearly 20 years; maybe it's good enough to be able to do ML work. But the heavy lifting library in C/C++ plus the high-level driving Python is a really good fit.

1 comments

Well, it is slightly different than multiplying two scalars:

c = a * b

vs

C = A @ B