abhi9u@lemmy.world to Technology@lemmy.worldEnglish · 17 days agoPython Performance: Why 'if not list' is 2x Faster Than Using len()blog.codingconfessions.comexternal-linkmessage-square151linkfedilinkarrow-up1218arrow-down124cross-posted to: python@programming.dev
arrow-up1194arrow-down1external-linkPython Performance: Why 'if not list' is 2x Faster Than Using len()blog.codingconfessions.comabhi9u@lemmy.world to Technology@lemmy.worldEnglish · 17 days agomessage-square151linkfedilinkcross-posted to: python@programming.dev
minus-squareFooBarrington@lemmy.worldlinkfedilinkEnglisharrow-up1arrow-down1·edit-216 days agoYes, the first example does the same thing, but there’s still less to mentally parse. Ideally you should just use if len(my list) == 0:.
Yes, the first example does the same thing, but there’s still less to mentally parse. Ideally you should just use
if len(my list) == 0:
.