set and dict iteration

Dave Angel davea at dejaviewphoto.com
Thu Aug 16 19:11:19 EDT 2012


On 08/16/2012 05:26 PM, Paul Rubin wrote:
> Dave Angel <d at davea.name> writes:
>> Everything else is implementation defined.  Why should an implementation
>> be forced to have ANY extra data structure to detect a static bug in the
>> caller's code?
> For the same reason the interpreter checks for type errors at runtime
> and raises TypeError, instead of letting the program go into the weeds.

There's an enormous difference between type errors, which affect the low
level dispatch, and checking for whether a dict has changed and may have
invalidated the iterator.  If we were really going to keep track of what
iterators are tracking a given dict or set, why stop there?  Why not
check if another process has changed a file we're iterating through?  Or ...





More information about the Python-list mailing list