[Python-3000] Iterators for dict keys, values, and items == annoying :)
Nick Coghlan
ncoghlan at gmail.com
Fri Mar 24 12:12:55 CET 2006
Brett Cannon wrote:
> On 3/23/06, Guido van Rossum <guido at python.org> wrote:
>> (Off-topic: maybe we can drop the fall-back behavior
>> of iter() if __iter__ isn't found?)
>>
>
> I say yes. Iterators will be common enough that objects that want the
> support should just directly support it.
Hmm, I'd expect the typical generator used for this to be a fair bit slower
than the current custom sequence iterator:
def __iter__(self):
for i in range(len(self)):
yield i
OTOH, it would make sense if the fallback could instead be written:
__iter__ = itertools.iterseq
(where 'iterseq' gives a real name to the currently hidden default sequence
iterator)
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-3000
mailing list