Re: CPython 2.7: Weakset data changing size during internal iteration

2012-06-03 Thread Steven D'Aprano
On Fri, 01 Jun 2012 20:24:30 -0700, Temia Eszteri wrote: On 02 Jun 2012 03:05:01 GMT, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I doubt that very much. If you are using threads, it is more likely your code has a race condition where you are modifying a weak set at the same

Re: CPython 2.7: Weakset data changing size during internal iteration

2012-06-03 Thread Temia Eszteri
On 03 Jun 2012 16:20:11 GMT, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: And should I have known this from your initial post? I did discuss the matter with Terry Reedy, actually, but I guess since the newsgroup-to-mailing list mirror is one-way, there's no actual way you could've

Re: CPython 2.7: Weakset data changing size during internal iteration

2012-06-02 Thread Terry Reedy
On 6/1/2012 7:40 PM, Temia Eszteri wrote: Given that len(weakset) is defined (sensibly) as the number of currently active members, it must count. weakset should really have .__bool__ method that uses any() instead of sum(). That might reduce, but not necessarily eliminate your problem. Think

CPython 2.7: Weakset data changing size during internal iteration

2012-06-01 Thread Temia Eszteri
I've got a bit of a problem - my project uses weak sets in multiple areas, the problem case in particular being to indicate what objects are using a particular texture, if any, so that its priority in OpenGL can be adjusted to match at the same time as it being (de)referenced by any explicit

Re: CPython 2.7: Weakset data changing size during internal iteration

2012-06-01 Thread Terry Reedy
On 6/1/2012 11:23 AM, Temia Eszteri wrote: I've got a bit of a problem - my project uses weak sets in multiple areas, the problem case in particular being to indicate what objects are using a particular texture, if any, so that its priority in OpenGL can be adjusted to match at the same time as

Re: CPython 2.7: Weakset data changing size during internal iteration

2012-06-01 Thread Temia Eszteri
On Fri, 01 Jun 2012 18:42:22 -0400, Terry Reedy tjre...@udel.edu wrote: I gather that the .references attribute is sometimes/always a weakset. To determine its boolean value, it computes its length. For regular sets, this is sensible as .__len__() returns a pre-computed value. Indeed. Back

Re: CPython 2.7: Weakset data changing size during internal iteration

2012-06-01 Thread Steven D'Aprano
On Fri, 01 Jun 2012 08:23:44 -0700, Temia Eszteri wrote: I've got a bit of a problem - my project uses weak sets in multiple areas, the problem case in particular being to indicate what objects are using a particular texture, if any, so that its priority in OpenGL can be adjusted to match at

Re: CPython 2.7: Weakset data changing size during internal iteration

2012-06-01 Thread Temia Eszteri
On 02 Jun 2012 03:05:01 GMT, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I doubt that very much. If you are using threads, it is more likely your code has a race condition where you are modifying a weak set at the same time another thread is trying to iterate over it (in this