The `groupby_alt` that I posted in the above *always* performs better than using a `try-except` here.  You should really test `groupby_alt` too!

> I get only modest improvements on my tiny benchmark though.

Yeah, the improvements can indeed be modest, but they are most significant when many items are the same.  Also, the new implementation is *always* better than the old implementation for my benchmarks, including all the same, all different, and tiny `seq`.