[New-bugs-announce] [issue25513] collections.abc.Iterable don't implement __bool__

yoch report at bugs.python.org
Thu Oct 29 15:38:24 EDT 2015


New submission from yoch:

collections.abc.Iterable don't implement the __bool__ method. This may seriously degrade performance in case __len__ is not efficient.

I suggest to implement it as :

class Iterable:
    ...
    def __bool__(self):
        try:
            next(iter(self))
            return True
        except StopIteration:
            return False

----------
components: Library (Lib)
messages: 253690
nosy: yoch.melka
priority: normal
severity: normal
status: open
title: collections.abc.Iterable don't implement __bool__
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25513>
_______________________________________


More information about the New-bugs-announce mailing list