On Fri, May 15, 2015 at 8:14 PM, Steven D'Aprano
<steve+comp.lang.pyt...@pearwood.info> wrote:
> (If anything, using an implicit boolean test will be faster than an
> explicit manual test, because it doesn't have to call the len() global.)

Even more so: Some objects may be capable of determining their own
lengths, but can ascertain their own emptiness more quickly. So len(x)
might have to chug chug chug to figure out exactly how many results
there are (imagine a database query or something), where bool(x)
merely has to see whether or not a single one exists (imagine a
database query with "LIMIT 1" tacked on).

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to