On 9/22/06, Brian Harring <[EMAIL PROTECTED]> wrote:
> On Fri, Sep 22, 2006 at 12:05:19PM -0700, Bob Ippolito wrote:
> > On 9/22/06, Josiah Carlson <[EMAIL PROTECTED]> wrote:
> > >
> > > Michael Foord <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Hello all,
> > > >
> > > > I have a suggestion for a new Python built in function: 'flatten'.
> > >
> > > This has been brought up many times.  I'm -1 on its inclusion, if only
> > > because it's a fairly simple 9-line function (at least the trivial
> > > version I came up with), and not all X-line functions should be in the
> > > standard library.  Also, while I have had need for such a function in
> > > the past, I have found that I haven't needed it in a few years.
> >
> > I think instead of adding a flatten function perhaps we should think
> > about adding something like Erlang's "iolist" support. The idea is
> > that methods like "writelines" should be able to take nested iterators
> > and consume any object they find that implements the buffer protocol.
>
> Which is no different then just passing in a generator/iterator that
> does flattening.
>
> Don't much see the point in gumming up the file protocol with this
> special casing; still will have requests for a flattener elsewhere.
>
> If flattening was added, should definitely be a general obj, not a
> special casing in one method in my opinion.

I disagree, the reason for iolist is performance and convenience; the
required indirection of having to explicitly call a flattener function
removes some optimization potential and makes it less convenient to
use.

While there certainly should be a general mechanism available to
perform the task (easily accessible from C), the user would be better
served by not having to explicitly call itertools.iterbuffers every
time they want to write recursive iterables of stuff.

-bob
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to