Serhiy Storchaka added the comment:

Applied optimizations:

1) Used cached get() method instead of indexing. This optimization already was 
used in update() and subtract().
2) _keep_positive() is optimized for the case when most counts are not positive 
(common case for substraction and intersection).
3) __add__ and __or__ are defined via inplace operations which are faster (due 
to fast copying and _keep_positive()).
4) Inlined and simplified the code for __pos__ and __neg__.

May be following optimization can be made by implementing _keep_positive() in C.

----------

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

Reply via email to