Sets vs lists loop behaviour if size changes

Michiel Overtoom motoom at xs4all.nl
Wed Oct 14 17:36:08 EDT 2015


> On 14 Oct 2015, at 23:11, candide via Python-list <python-list at python.org> wrote:
> 
> If set size changes during a for loop, a runtime exception is raised

A set is a kind of dictionary (without values). And why it can't be resized, is explained by Brandon Rhodes in his excellent talk 'The Mighty Dictionary', https://www.youtube.com/watch?v=C4Kc8xzcA68 , starting at 21:24 "Because of resizing, a dictionary (or set) can completely reorder during an otherwise innocent insert".

Greetings,





More information about the Python-list mailing list