aahz at pythoncraft.com
Wed Jul 8 21:33:57 CEST 2009
In article <050094ea-faf4-4e03-875d-9c2c63090a89 at y17g2000yqn.googlegroups.com>,
Bearophile <bearophileHUGS at lycos.com> wrote:
>> from itertools import groupby
>> for x, g in groupby([fields for fields in data]):
>> =A0 =A0 print x, len(tuple(g))
>Avoid that len(tuple(g)), use something like the following, it's lazy
>and saves some memory.
The question is whether it saves time, have you tested it?
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"as long as we like the same operating system, things are cool." --piranha
More information about the Python-list