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

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

I don’t really understand the point about exceptions. Yeah “not foo” cannot throw an exception. But the program should crash if an invalid input is provided. If the function expects an optional[list] it should be provided with either a list or None, nothing else.

source
Sort:hotnewtop