[issue36781] Optimize sum() for bools

Serhiy Storchaka report at bugs.python.org
Sun Jun 2 02:08:31 EDT 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

I am not sure that this optimization should be added. sum(pred(x) for x in data) will be always slower than sum(1 for x in data if pred(x)) because more items is passed to sun() in the former case. It can be considered as an anti-pattern.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36781>
_______________________________________


More information about the Python-bugs-list mailing list