Wolfgang Maier added the comment: In principle, your approach using itertools.groupby, the existing _sum, your decimalsum, and my _ExactRatio class could be combined.
You could call decimalsum for Decimal and subclasses, the current _sum for everything else. _sum would return an _ExactRatio instance now anyway, just modify decimalsum accordingly and you are done. The problem I see is that it would cause a slow down in many cases where no Decimals or just a few are involved (think of mixes of ints and floats as a realistic scenario, and consider also that you would have to do an isinstance check to catch subclasses of Decimal). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20499> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com