set and dict iteration
Aaron Brady
castironpi at gmail.com
Sat Sep 8 11:42:56 EDT 2012
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?
More information about the Python-list
mailing list