itertools.flatten()? and copying generators/iterators.

Francis Avila francisgavila at yahoo.com
Thu Oct 30 03:54:30 EST 2003


"Peter Otten" <__peter__ at web.de> wrote in message
news:bnqih2$v3c$01$1 at news.t-online.com...
> Francis Avila wrote:
>
> >> for flatten_dict(). So you get some speed up at the cost of uglier
though
> >> still quite readable code and under the assumption that either all or
no
> >> instances of a class are iterable.
> >
> > That's not always a good assumption to make, if we want to decide
whether
> > to iterate based upon some property of the object (which is actually how
I
> > originally discovered I needed a "flatten").
> >
> > Perhaps we can combine both conditions and caching optimizations?
>
> I didn't work this out, but I suppose the way to go is to allow three
states
> (ALWAYS, NEVER, NOCACHE) in the dictionary and only invoke itercond() on
> cache misses and NOCACHE values.
>
> Peter

Hah, just finished writing the post the moment you





More information about the Python-list mailing list