Received: by 10.224.28.15 with SMTP id k15mr1559643qac.8.1347118976632; Sat, 08 Sep 2012 08:42:56 -0700 (PDT) Received: by 10.236.75.3 with SMTP id y3mr1371158yhd.20.1347118976574; Sat, 08 Sep 2012 08:42:56 -0700 (PDT) Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.216.87.MISMATCH!v8no54367qap.0!news-out.google.com!da15ni1572qab.0!nntp.google.com!b19no84242qas.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.python Date: Sat, 8 Sep 2012 08:42:56 -0700 (PDT) In-Reply-To: <50456073$0$29978$c3e8da3$5496439d@news.astraweb.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=67.184.78.189; posting-account=MQ3pigoAAACeFzUFjVAePnOjOJMNlvq9 NNTP-Posting-Host: 67.184.78.189 References: <7xy5le7cli.fsf@ruckus.brouhaha.com> <502dab6c$0$29978$c3e8da3$5496439d@news.astraweb.com> <1567e8c7-a2bb-41f4-9be8-18e9f4d063cb@googlegroups.com> <504558cb$0$29978$c3e8da3$5496439d@news.astraweb.com> <50456073$0$29978$c3e8da3$5496439d@news.astraweb.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <87f103a7-2bbd-405f-8a5e-3aaf02c80fff@googlegroups.com> Subject: Re: set and dict iteration From: Aaron Brady Injection-Date: Sat, 08 Sep 2012 15:42:56 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.python:28726 On Monday, September 3, 2012 8:59:16 PM UTC-5, Steven D'Aprano wrote: > On Mon, 03 Sep 2012 21:50:57 -0400, Dave Angel wrote: > > > > > On 09/03/2012 09:26 PM, Steven D'Aprano wrote: > > > > >> An unsigned C int can count up to 4,294,967,295. I propose that you say > > >> that is enough iterators for anyone, and use a single, simple, version > > >> counter in the dict and the iterator. If somebody exceeds that many > > >> iterators to a single dict or set, > > > > > > I think you have the count confused. it has to be a count of how many > > > changes have been made to the dict or set, not how many iterators exist. > > > > Oops, yes you are absolutely right. It's a version number, not a count of > > iterators. > > > > > > -- > > Steven Hello. We have a number of proposed solutions so far. 1) Collection of iterators a) Linked list i) Uncounted references ii) Counted references iii) Weak references b) Weak set 2) Serial index / timestamp a) No overflow - Python longs b) Overflow - C ints / shorts / chars c) Reset index if no iterators left 3) Iterator count - Raise exception on set modifications, not iteration Note, "2b" still leaves the possibility of missing a case and letting an error pass silently, as the current behavior does. The rest catch the error 100% of the time. Anyway, I plan to develop the above patch for the 'dict' class. Would anyone like to take over or help me do it?