Operator Precedence/Boolean Logic
lawrencedo99 at gmail.com
Sat Jun 25 01:38:40 EDT 2016
On Thursday, June 23, 2016 at 9:57:35 PM UTC+12, Marko Rauhamaa wrote:
> Lawrence D’Oliveiro:
>> On Thursday, June 23, 2016 at 9:11:05 PM UTC+12, Marko Rauhamaa wrote:
>>> The __len__ method is not guaranteed to execute in O(1).
>> So what is?
> The __bool__ method is the appropriate place to implement an efficient
> emptiness check. It might not be O(1) but it will be the most efficient
> way to check for emptiness, or the class is badly implemented.
Saying “or the class is badly implemented” sounds like circular reasoning...
More information about the Python-list