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

<- View Parent
LegoBrickOnFire@lemmy.world ⁨2⁩ ⁨days⁩ ago

Well, in your case it is not clear whether you intended to branch in the variable foo being None, or on the list being empty which is semantically very different…

Thats why it’s better to explicitelly express whether you want an empty collection (len = 0) or a None value.

source
Sort:hotnewtop