On Sep 11, 2008, at 6:44 AM, C. Titus Brown wrote:

> There is, in general, a confusion in the pygr code caused by  
> inheriting
> from 'dict'.  In several places, as in AnnotationDB, the built-in  
> 'dict'
> functions that *aren't* overridden deal with the internal 'dict' data
> structures, while the ones that *are* overridden do other things.  It
> can be hard to tell what any particular function is supposed to be
> doing, frankly.  I've been working on regularizing the dict  
> interfaces,
> hence the removal of 'clear' on AnnotationDB.
>
> I am beginning to think the best way forward would be to go in and
> remove 'dict' from the superclasses of any of the pygr classes; for
> example AnnotationDB would change from this:

I already did that a couple weeks ago for SequenceDB, and did the same  
thing for SQLTable and AnnotationDB yesterday.  The class declarations  
look like this:

class SequenceDB(object, UserDict.DictMixin):
    ...

Another change that is important for memory usage is that the "cache  
dictionary" is now stored using a weakref.WeakValueDictionary, so it  
will automatically free objects that the user is no longer holding a  
reference to.  That behavior is controlled using a new option autoGC  
for the constructor, which is True by default; if False, a regular  
dict is used instead of a WeakValueDictionary.  I also extended  
NLMSASlice so that whenever it instantiates a sequence object, it  
holds on to a reference to it (using the same cache owner object that  
Titus originally introduced), so that it in turn will be kept in the  
sequenceDB's cache dictionary until the NLMSASlice object itself is  
released by the user.  I added tests of this functionality to Titus'  
caching test in the test suite.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pygr-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pygr-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to