209
Python Performance: Why 'if not list' is 2x Faster Than Using len()
(blog.codingconfessions.com)
This is a most excellent place for technology news and articles.
That's worse. IMO, solve this problem with two things:
mylist
aslist | None
or justlist
if not mylist:
The first documents intent and gives you static analysis tools some context to check for type consistency/compatibility, and the second shows that
None
vs empty isn't an important distinction here.