[Python-3000] Builtin iterator type
George Sakkis
george.sakkis at gmail.com
Tue Nov 14 20:32:22 CET 2006
On 11/14/06, Fred L. Drake, Jr. <fdrake at acm.org> wrote:
> On Tuesday 14 November 2006 13:06, George Sakkis wrote:
> > I understand you are exaggerating (can't believe you are seriously
> > claiming that cmath or traceback are more frequently used than
> > itertools),
>
> I certainly use traceback far more than itertools. I use traceback
> occaissionally, but I've never actually had reason to use itertools at all.
I believe you, but I doubt your usage patterns are close to the
average python user. I am sure cmath is invaluable to some people too.
There's also a chicken and egg problem; the reason itertools are not
used as often as they could is exactly the overheard of importing a
module and use a verbose function, rather than having them for free as
methods of a builtin object. If instead of
for k,v in some_dict.iteritems():
I had to do something like
from dictutils import iteritems
for k,v in iteritems(some_dict):
I'd probably woudn't bother and just use some_dict.items().
> > but if your objection is on adding yet another builtin,
> > what would be the objection to boosting up the existing iter() to
> > provide this extra functionality ? This might even be backwards
> > compatible (but even if it's not, that's not a main concern for
> > py-3k).
>
> The real issue seems to be that there's no benefit. Iterators are nice
> because they're composable; that doesn't make the compositions part of the
> iterator, though.
Seems like a classic case for OOP to me: combine state (iterables)
with behavior (iter) in handly little packets (objects).
George
More information about the Python-3000
mailing list