[issue45851] statistics.multimode is inefficient (time and space) (mode somewhat, too)

2021-11-20 Thread Stefan Pochmann
Stefan Pochmann added the comment: Ok, thanks, had somewhat expected that, as the multimode proposal was rather clearly better but the mode proposal not so much. -- ___ Python tracker __

[issue45851] statistics.multimode is inefficient (time and space) (mode somewhat, too)

2021-11-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: Accepting the suggestion for multimode() to use max() instead of a full sort. This is a nice improvement. Thank you. Leaving mode() as-is. The existing code is cleaner and does its work in a single pass over the counter. -- resolution: -> fix

[issue45851] statistics.multimode is inefficient (time and space) (mode somewhat, too)

2021-11-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 04e03f496cf7da48ce4f545b41579d7d45f59ad2 by Raymond Hettinger in branch 'main': bpo-45851: Avoid full sort in statistics.multimode() (#29662) https://github.com/python/cpython/commit/04e03f496cf7da48ce4f545b41579d7d45f59ad2 --

[issue45851] statistics.multimode is inefficient (time and space) (mode somewhat, too)

2021-11-20 Thread Raymond Hettinger
Change by Raymond Hettinger : -- keywords: +patch pull_requests: +27904 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29662 ___ Python tracker __

[issue45851] statistics.multimode is inefficient (time and space) (mode somewhat, too)

2021-11-20 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: htt

[issue45851] statistics.multimode is inefficient (time and space) (mode somewhat, too)

2021-11-20 Thread Alex Waygood
Change by Alex Waygood : -- nosy: +rhettinger, steven.daprano ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45851] statistics.multimode is inefficient (time and space) (mode somewhat, too)

2021-11-19 Thread Stefan Pochmann
Stefan Pochmann added the comment: (somehow the benchmark script didn't get attached, trying again) -- Added file: https://bugs.python.org/file50453/multimode_mode.py ___ Python tracker _

[issue45851] statistics.multimode is inefficient (time and space) (mode somewhat, too)

2021-11-19 Thread Stefan Pochmann
New submission from Stefan Pochmann : The current implementation is: def multimode(data): counts = Counter(iter(data)).most_common() maxcount, mode_items = next(groupby(counts, key=itemgetter(1)), (0, [])) return list(map(itemgetter(0), mode_items)) The most_common() does a complet