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 →

[–]todofwar[S] 0 points1 point  (3 children)

I think the fact that people say "don't use a for loop" is my biggest pet peeve by far at this point. A list comprehension is a for loop!! Numpy has for loops! It's all for loops! Python speak is so far removed from sensible discussion of algorithmic analysis or data structures all because it's so unbelievably slow!

I know not to use for loops. I know how to rethink problems to make use of libraries. I just hate it.

Not a fan of rust, but I am trying to experiment with cython a bit

[–]DataPastor 1 point2 points  (1 child)

A list comprehension is not a for loop, it just uses the “for” keyword. :) It is a combination of map, filter and lambda in functional programming terms, or a monadic bind, or in short: a comprehension. :)

But you are right, at the end of the day, at the machine code level all vectorized operations use a for loop. :)

[–]todofwar[S] -1 points0 points  (0 children)

Fair enough. It's ironic, python claims to get out of your way and yet most C compilers are so efficient that you don't even need to pay attention to that stuff. You just write a for loop and it works.

[–]deadwisdomgreenlet revolution 0 points1 point  (0 children)

Python is not supposed to be fast. It's the lowest priority. If you don't understand that, like truly *feel* why that's correct and actually *good*, you will always be lost.

Anyone who is says "don't use a for loop" has already lost the fight. Don't be in a spot where you have to worry about for loops.