Re: [pygame] weakref WeakKeyDictionary machinery.

2008-06-01 Thread Charlie Nolan
And why are you asking us?  This is the pygame mailing list, last I
checked, and a quick search of the code suggests that pygame doesn't
use either Weak*Dictionary.

On 6/1/08, Gabriel Hasbun [EMAIL PROTECTED] wrote:
 Hello I searched the whole web for good examples on weakref module's
 WeakKeyDictionary, but have found none, All I find is the Python Docs
 explanations, and some examples which actually doesn't explain how the
 mechanism of key reference removal works:

 import weakref
 class Tracking:
 _instances_dict = weakref.WeakValueDictionary(  )
 _num_generated = 0
 def _ _init_ _(self):
 Tracking._num_generated += 1
 Tracking._instances_dict[Tracking._num_generated] = self
 def instances(  ): return _instances_dict.values(  )
 instances = staticmethod(instances)






[pygame] weakref WeakKeyDictionary machinery.

2008-06-01 Thread Gabriel Hasbun
Hello I searched the whole web for good examples on weakref module's 
WeakKeyDictionary, but have found none, All I find is the Python Docs 
explanations, and some examples which actually doesn't explain how the 
mechanism of key reference removal works:

import weakref
class Tracking:
_instances_dict = weakref.WeakValueDictionary(  )
_num_generated = 0
def _ _init_ _(self):
Tracking._num_generated += 1
Tracking._instances_dict[Tracking._num_generated] = self
def instances(  ): return _instances_dict.values(  )
instances = staticmethod(instances)