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

<- View Parent
sugar_in_your_tea@sh.itjust.works ⁨2⁩ ⁨days⁩ ago

That’s why we use type-hinting at my company:

def do_work(foo: list | None):
    if not foo:
        return
    ...

Boom, self-documenting, faster, and very simple.

source
Sort:hotnewtop