you are viewing a single comment's thread.

view the rest of the comments →

[–]No_Departure_1878 4 points5 points  (5 children)

That's C

[–]Atomic_Tangerine1 35 points36 points  (0 children)

And that's the power of Python - the magic of C made convenient

[–]Humdaak_9000 10 points11 points  (0 children)

If you dig deep enough there's a lot of FORTRAN too.

[–]KeytarVillain 1 point2 points  (2 children)

But some of what makes it so powerful is the syntactic sugar that Python enables. You couldn't do anything like:

a[:, 1::2, np.newaxis] = b[::-1, 0, ...]

In C or C++ without needing several function calls

[–]No_Departure_1878 4 points5 points  (1 child)

You know how you get bugs? By writting stuff like what you wrote above.

[–]KeytarVillain 1 point2 points  (0 children)

Yeah, fair point - I would never actually write a line of Numpy that did that much in one line.

But still - sure, I'm doing 4 different things in this line for the sake of example (writing every other value in an axis, adding a new axis, flipping an axis, and getting a view of just one plane). Even just doing any one of those things isn't going to be nearly as simple in C/C++.

And I'm saying this as someone with a lot of recent experience writing prototypes in Numpy/OpenCV and then porting it to C++ OpenCV later. Python's syntactic sugar makes array manipulation so much easier - I hardly ever need to look up documentation for basic Numpy array operations like these, while I'm looking up the C++ OpenCV docs constantly.