[Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception (original) (raw)
Chris Angelico rosuav at gmail.com
Tue Dec 13 13:17:06 EST 2016
- Previous message (by thread): [Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception
- Next message (by thread): [Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Dec 14, 2016 at 5:13 AM, Joe Jevnik <jjevnik at quantopian.com> wrote:
Is it possible to add a key, triggering a resize of the dict, then remove one, and continue iterating through the old (deallocated) memory? You can add and remove keys between calling next which would resize the dictionary; however, it will not iterate through uninitialized memory. The dictiter holds the current index and each time next is called it goes directly to makeys->dkentries[savedindex] or mavalues[savedindex]
Okay, so it's fine then. Cool. Thanks for the info.
ChrisA
- Previous message (by thread): [Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception
- Next message (by thread): [Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]