PEP 234: Iterators
Toby Dickenson
tdickenson at devmail.geminidataloggers.co.uk
Tue May 1 06:35:15 EDT 2001
Guido van Rossum <guido at digicool.com> wrote:
>Dictionary Iterators
>
> This means that we can write
>
> for k in dict: ...
>
> which is equivalent to, but much faster than
faster at runtime, and less typing too ;-)
>
> for k in dict.keys(): ...
>
> as long as the restriction on modifications to the dictionary
> (either by the loop or by another thread) are not violated.
What happens if you do violate this? I assume that damage is limited
to seing elements twice, or skipping some elements and not seeing them
at all.
Toby Dickenson
tdickenson at geminidataloggers.com
More information about the Python-list
mailing list