Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'matches': 0.07; 'used.': 0.07; 'created,': 0.09; 'dict': 0.09; 'internally': 0.09; 'oh,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:set': 0.09; 'suggest': 0.11; 'yet.': 0.13; 'advanced,': 0.16; 'increment': 0.16; 'int.': 0.16; 'iterator': 0.16; 'iterator.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.17; 'alternate': 0.17; 'version.': 0.17; 'error.': 0.21; 'raise': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; 'hash': 0.29; 'modified,': 0.29; 'surprised': 0.29; "i'm": 0.29; 'to:addr:python-list': 0.33; 'version': 0.34; 'table': 0.35; 'received:org': 0.36; 'subject:: ': 0.38; 'store': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'received:46': 0.60; 'strategy': 0.64 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Serhiy Storchaka Subject: Re: set and dict iteration Date: Tue, 04 Sep 2012 00:46:31 +0300 References: <7xy5le7cli.fsf@ruckus.brouhaha.com> <502dab6c$0$29978$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 46.185.98.182 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346708810 news.xs4all.nl 6979 [2001:888:2000:d::a6]:40443 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28372 On 27.08.12 22:17, Ian Kelly wrote: > May I > suggest an alternate approach? Internally tag each set or dict with a > "version", which is just a C int. Every time the hash table is > modified, increment the version. When an iterator is created, store > the current version on the iterator. When the iterator is advanced, > check that the iterator version matches the dict/set version. If > they're not equal, raise an error. Oh, I'm surprised that this strategy is not used yet. I was sure that it is used.