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 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 known. :/ Sigh, another problem out

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 > 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

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

2012-06-01 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

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 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 case, to >determine it's length), a

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

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 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 when I

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

2012-06-01 Thread Terry Reedy
.Sprite("testbullet", 0) File "C:\foo\bar\video.py", line 95, in __init__ self.opengl_id = reference_texture(self, target) File "C:\foo\bar\video.py", line 310, in reference_texture if not video_handler.textures[target].references: I gather that the

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 calls.

Re: weakSet

2006-10-05 Thread Gabriel Genellina
At Thursday 5/10/2006 13:53, [EMAIL PROTECTED] wrote: Has anyone ever think about a set wich references its elements weakly ? The *easy* solution would provide a WeakSet class with the following behavior: >>>s=set([a, b]) >>>ws=WeakSet([b,c]) >>>(ws&s).__cl

Re: weakSet

2006-10-05 Thread Tim Peters
nterface for our needs. class WeakSet(object): """A set of objects that doesn't keep its elements alive. The objects in the set must be weakly referencable. The objects need not be hashable, and need not support comparison. Two objects are considered to be the sa

weakSet

2006-10-05 Thread jean . philippe . mague
Hello, Has anyone ever think about a set wich references its elements weakly ? The *easy* solution would provide a WeakSet class with the following behavior: >>>s=set([a, b]) >>>ws=WeakSet([b,c]) >>>(ws&s).__class__() is WeakSet True >>>s&ws TypeError: