On Feb 13, 5:09 pm, Giovanni Bajo <[EMAIL PROTECTED]> wrote: > > The itertools.repeat(const).next approach wins on speed and > > flexibility. > > But it's the most unreadable too.
Not really. It's unusual but plenty readable (no surprise that repeat(0) repeatedly gives you zero). I think it more surprising that int() with no arguments gives you a zero. > I'm surprised that defaultdict(int) is > slower than the lambda one though. What's the reason? All that comes to mind is that int() has to call PyArg_ParseTupleAndKeywords() while the lambda is unburdened by argument passing. Raymond -- http://mail.python.org/mailman/listinfo/python-list