Re:Show HN: Array – A Better Python List
by orf on Sunday January 10, 2021 @01:51PM
(#25718055)
Yes, len() with the basic types are not expensive, and it can vary based on the container implementation, but that’s not really the point.
The reason you should use “if x” is the same reason you should use “if x not in y” rather than “if not x in y”. It better expresses the semantics of your operation with the side effect that it may be faster.
The reason you should use “if x” is the same reason you should use “if x not in y” rather than “if not x in y”. It better expresses the semantics of your operation with the side effect that it may be faster.