[Python-3000] Iterators for dict keys, values, and items == annoying :)

adam deprince adam.deprince at gmail.com
Tue Mar 28 07:32:08 CEST 2006


<snip>

> I think an even bigger problem is either
> (1)  checking isvalid on every *lookup*, or
> (2)  the mess and inefficiency of forcing every (mutable) collection to
> (weakly) track all its iterators, and forcing every iterator to have
> methods for handling notification.  (So now "for k in dict" needs
> to allocate (and deallocate) an extra weakref, and to do an extra
> insert  and delete on the weakrefs list ... OK for large stable
> objects like
> a module, but not good for large numbers of three-item dicts.)

I agree about #2 whole heartedly ... as for #1, well, dict.iter does
this to some extent ... each call to .next entails confirming that the
dict and iter agree about the size of the former.

I'm not going address these right now because I'm tossing this PEP ...
now that I reread it myself I don't really like it.   (Things always
look good right before you submit them.)  I've going to backtrack and
describe a Java views style proposal that concrete classes can
implement.

Cheers - Adam DePrince


>
> -jJ
>


More information about the Python-3000 mailing list