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

<- View Parent
CompassRed@discuss.tchncs.de ⁨4⁩ ⁨days⁩ ago

It’s not the same, and you kinda answered your own question with that quote. Consider what happens when an object defines both dunder bool and dunder len. It’s possible for dunder len to return 0 while dunder bool returns True, in which case the falsy-ness of the instance would not depend at all on the value of len

source
Sort:hotnewtop