[issue23509] Speed up Counter operators
Serhiy Storchaka
report at bugs.python.org
Tue Feb 24 13:44:22 CET 2015
Serhiy Storchaka added the comment:
However it is possible to speed up the implementation. Proposed patch increases performance of Counter operators from 20% to 1200%.
Unpatched Patched
422 (-3%) 411 c = Counter(a)
260 (-4%) 251 c = Counter(b)
15568 (-118%) 7155 c = Counter(a); c + b
11536 (-56%) 7377 c = Counter(a); c - b
15354 (-190%) 5291 c = Counter(a); c | b
11291 (-60%) 7043 c = Counter(a); c & b
8176 (-22%) 6712 c = Counter(a); c += b
21976 (-162%) 8379 c = Counter(a); c -= b
6090 (-24%) 4895 c = Counter(a); c |= b
16346 (-34%) 12226 c = Counter(a); c &= b
17125 (-1160%) 1359 +a
10484 (-289%) 2693 +c # c = Counter(); c.subtract(a)
3325 (-234%) 997 -a
10094 (-56%) 6480 -c # c = Counter(); c.subtract(a)
----------
components: +Library (Lib)
keywords: +patch
resolution: out of date ->
stage: -> patch review
title: Counter.__iadd__ falls back to __add__ with bad performance impact -> Speed up Counter operators
versions: +Python 3.5 -Python 2.7, Python 3.4
Added file: http://bugs.python.org/file38224/counter_faster.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23509>
_______________________________________
More information about the Python-bugs-list
mailing list