[Python-Dev] "groupby" iterator

Guido van Rossum guido at python.org
Fri Nov 28 16:46:53 EST 2003


> Here's yet another implementation for itertoolsmodule.c. (see
> attachment) I wrote it after the shower (really!) :)

Wow!  Thanks.  Let's all remember to take or showers and maybe Python
will become the cleanest programming language. :)

Raymond, what do you think?

I would make one change: after looking at another use case, I'd like
to change the outer iterator to produce (key, grouper) tuples.  This
way, you can write things like

  totals = {}
  for key, group in sequence:
      totals[key] = sum(group)

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list