|
Re: Support for Indexing and Iteration Safety: msg#00348python.c++
> >>> x = foo[10].bar > >>> del foo[10] # erase the 10th item > >>> print x What about having x a weak reference which del will reset to None. > >>> x = foo[10] > >>> foo[10] = y > >>> print x, y > > Now you'll see that x and y are always identical, because x > refers to the place in the array where you've written the > value of y. It's ok, because Python have explicit copy semantics The list isn't the only model. > 4. Similar problem with exposed iterators: > change out from under you. The above could lead to a crash > or bogus results. bogus results are ok because it's the same as in Python - changing a list under loop can lead to skiping an element or visiting it twice. > know how many people care. I think if it will put some restriction on usage it is ok with me. Mike |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Support for Indexing and Iteration Safety: 00348, Mike Rovner |
|---|---|
| Next by Date: | Re: Support for Indexing and Iteration Safety: 00348, David Abrahams |
| Previous by Thread: | Re: Support for Indexing and Iteration Safetyi: 00348, Mike Rovner |
| Next by Thread: | Re: Support for Indexing and Iteration Safety: 00348, David Abrahams |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |