Comment on Python Performance: Why 'if not list' is 2x Faster Than Using len()

<- View Parent
thebestaquaman@lemmy.world ⁨6⁩ ⁨days⁩ ago

I definitely agree that len is the preferred choice for checking the emptiness of an object, for the reasons you mention. I’m just pointing out that assuming a variable is a bool because it’s used in a Boolean context is a bit silly, especially in Python or other languages where any object can have a truthiness value, and where this is commonly utilised.

source
Sort:hotnewtop