Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

The cause of len() been faster than bool() is the same as why repr() is faster 
than str(). [1] len() and repr() are functions that just call corresponding 
slots, while bool() and str() are constructors.

In most cases you shouldn't use `bool(obj)` or `len(obj) > 0`. Instead use just 
`obj` in conditions.

If you can provide a patch that speeds up constructions of simple class 
instances, please open a pull request on GitHub. Otherwise this issue will be 
closed.

[1] 
https://stackoverflow.com/questions/45376719/why-is-reprint-faster-than-strint

----------
nosy: +serhiy.storchaka
status: open -> pending
versions: +Python 3.7 -Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32180>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to