[Python-ideas] Break the dominance of boolean values in boolean context
Amaury Forgeot d'Arc
amauryfa at gmail.com
Fri Sep 16 08:16:58 CEST 2011
Hi,
Le 15 sept. 2011 19:55, "Alexander Belopolsky" <
alexander.belopolsky at gmail.com> a écrit :
> Did you consider that in a typical "if any(S):" construct,
> x.__bool__() will be called twice on the found object? It is not
> unheard of to have expensive __bool__(). For example in a vector
> library a vector may be considered "false" if all its components are
> zero
It is the same for "a or b", even when a is true.
--
Amaury
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110916/63e8cf35/attachment.html>
More information about the Python-ideas
mailing list