4 ms·
>there is a trade-off between time saved by having functions in standard library and time spent looking those functions up. Meh, difficulty of writing such cod
by rubber_duck 10y ago
>there is a trade-off between time saved by having functions in standard library and time spent looking those functions up.
Meh, difficulty of writing such code is irrelevant in comparison to how these higher level functions read and compose, consider :
next(x for x in seq if x > y, None)
vs.
first(seq, lambda x: x > y, None)
seq.first(lambda x: x > y, None)
the intent is very clear in the second example, it just has useless implementation details in the first.
I haven't done python in a while but every time I go back to it I find such edge cases where the code ends up being obfuscated or you write one-off functions that you need in random places and should be in std. Contrast with Clojure for eg. with it's rich collection manipulation standard library - data manipulation is high level and expressive