ishanpage@programming.dev to Programming@programming.devEnglish · 2 years agoProgramming "with the grain"ishan.pageexternal-linkmessage-square4fedilinkarrow-up128arrow-down11
arrow-up127arrow-down1external-linkProgramming "with the grain"ishan.pageishanpage@programming.dev to Programming@programming.devEnglish · 2 years agomessage-square4fedilink
minus-squareishanpage@programming.devOPlinkfedilinkEnglisharrow-up3·2 years agoOTOH, the more pythonic one will probably perform worse, but I’m not familiar enough with Python internals to make that claim without benchmarks. I’ll try it out and add the data in the article
minus-squareHazzard@lemm.eelinkfedilinkEnglisharrow-up4·2 years agoEh, the python one will probably perform better, because sum is probably written in native C under the hood.
minus-squarejadero@programming.devlinkfedilinkEnglisharrow-up3·2 years agoI’ve yet to find a language where “doing it yourself” has higher performance than calling the built-in or library function. There are edge cases, but rarely enough to be bothered about.
OTOH, the more pythonic one will probably perform worse, but I’m not familiar enough with Python internals to make that claim without benchmarks.
I’ll try it out and add the data in the article
Eh, the python one will probably perform better, because
sum
is probably written in native C under the hood.I’ve yet to find a language where “doing it yourself” has higher performance than calling the built-in or library function. There are edge cases, but rarely enough to be bothered about.