Author matthew.brett
Recipients matthew.brett
Date 2017-02-02.14:10:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1486044645.48.0.643305374135.issue29420@psf.upfronthosting.co.za>
In-reply-to
Content
The behavior of dict iteration has changed in Python 3.6, in that inserting keys during iteration has a different and unpredictable affect.  For this code:

d = {'foo': 1}
for key in d:
   print(key)
   d.pop(key)
   d[key] = 1

Python 3.5 prints a single 'foo' (one pass through the loop).  Python 3.6 generates five lines of 'foo' (five passes through the loop).  Of course this code is pathological, but I found this behavior from a bug in code where the pathology was a lot less obvious - see https://github.com/nipy/nipy/issues/420
History
Date User Action Args
2017-02-02 14:10:45matthew.brettsetrecipients: + matthew.brett
2017-02-02 14:10:45matthew.brettsetmessageid: <1486044645.48.0.643305374135.issue29420@psf.upfronthosting.co.za>
2017-02-02 14:10:45matthew.brettlinkissue29420 messages
2017-02-02 14:10:45matthew.brettcreate