63
Python Performance: Why 'if not list' is 2x Faster Than Using len()
(blog.codingconfessions.com)
Welcome to the Python community on the programming.dev Lemmy instance!
Past
November 2023
October 2023
July 2023
August 2023
September 2023
"Many" isn't the same as "most," though I don't think there's any way to know what "most" is.
But here's my reason for agreeing w/ the OP:
not xchecks bothNoneand emptiness, which is usually desiredlen(x) == 0will raise an exception ifxis nullIt's nice that it's slightly faster, though performance has absolutely nothing to do w/ my preference, though it does have something to do with my preference for avoiding exceptions for non-exceptional cases.