python is slow because you used a loop
why did you write it yourself every problem has been solved you just need to find the right package
why did you write it yourself every problem has been solved you just need to find the right package
@deprecated_ii Heh. I agree that for loops are slow, but using the batteries isn't always the solution. Another solution is List and Dictionary Comprehensions. Written correctly, those will take a single loop of the interpreter, while a for loop will take many loops of the interpreter.
@kazriko Consider the larger context of what @deprecated_ii@poa.st was rallying about. I may be reading him wrong, but he is against thoughtless programming where you string abstractions and libraries together. He is against low-ability, pajeet programming that got us into a mess in many systems today. So, when I was working on the kernel, it was a given to consider a healthy balance between using a highly optimized, known good library function, and the obfuscation that piling library functions brings about. Sometimes it's okay to open-code something if it makes the code cleaner!
However, that was C. Python is unfortunately not a good example, because it actively punishes people making any loop. There's going to be a couple of orders of magnitude handicap between finding a standard library function, even doing a trivial thing, and open-coding it in Python.
And on the third level, if you look at the original quote, the guy started doing a good talk and then ruined it all with: "You do not use numpy directly in Python". This is yet another level of bullshit Python programming that is endemic in the community. My pet example of this is Requests: a largely worthless library that is a shim on top of the standard library. Its main objective is to make the API protocol "more pythonic". But it's a given for many Pythonista that Requests is the way to go. It's not only thoughtless programming we're seeing, but thoughtless thinking about the programming in Python.
But of course all of it my inference of a Fedi friend shitposting with a oneliner and a picture. He might've just been drunk :-)
However, that was C. Python is unfortunately not a good example, because it actively punishes people making any loop. There's going to be a couple of orders of magnitude handicap between finding a standard library function, even doing a trivial thing, and open-coding it in Python.
And on the third level, if you look at the original quote, the guy started doing a good talk and then ruined it all with: "You do not use numpy directly in Python". This is yet another level of bullshit Python programming that is endemic in the community. My pet example of this is Requests: a largely worthless library that is a shim on top of the standard library. Its main objective is to make the API protocol "more pythonic". But it's a given for many Pythonista that Requests is the way to go. It's not only thoughtless programming we're seeing, but thoughtless thinking about the programming in Python.
But of course all of it my inference of a Fedi friend shitposting with a oneliner and a picture. He might've just been drunk :-)
@pro Yeah, a lot of python has gotten a bit silly about that since the whole "lets build everything with Pandas!" trend started. Just noting that using C++ written libraries wasn't the only way to avoid the cost of python language for loops. Really it's the cost of the interpreter loop itself, and a for loop just means you're doing lots of interpreter loops. If you're trying to either transform a list, or extract parts out of a list, a list comprehension is far better than a for.
- replies
- 0
- announces
- 0
- likes
- 0