Python Performance: Why 'if not list' is 2x Faster Than Using len()
https://lemmy.world/post/28121911

Python Performance: Why 'if not list' is 2x Faster Than Using len() - Lemmy.World
Lemmy
Yea and then you use “not” with a variable name that does not make it obvious that it is a list and another person who reads the code thinks it is a bool. Hell a couple of months later you yourself wont even understand that it is a list. You should not sacrifice code readability for over optimization, this is phyton after all I don’t think list lengths will be your bottle neck.
Strongly disagree that not x implies to programmers that x is a bool.
well it does not imply directly per se since you can “not” many things but I feel like my first assumption would be it is used in a bool context
You can make that assumption at your own peril.