Book-keeping for UOW about dirty elements

Issue #998 resolved
Christian Theune created an issue

This is a note I took when working on SA during the PyCon 2008 sprint. We found that it is very expensive for the UOW to find out which objects are dirty. We thought it might be worthwhile to make the UOW do some book-keeping to allow answering the question faster.

Comments (5)

  1. Mike Bayer repo owner

    yeah....we're going to do what you recommended. The current logic that flips "state.modified" will be converted to a descriptor on InstanceState that flips a similar flag on the parent identity map object (currently WeakInstanceDict / StrongInstanceDict). UnitOfWork will use this flag for an immediate "dirty" check.

    For "mutable" attributes, the InstanceState will also get a list over to the identity map which stores all the "mutable" properties, possibly as a dict of MutableScalarAttributeImpl objects to sets of InstanceState objects which require a check on that attribute. this is a reasonably clean place to put it since InstanceState is already managing itself w.r.t the identity map.

    I think I also might want to lock down the API on the identity map classes, such that we do something like:

    identity_map.add(state)
    
    identity_map.remove(state)
    

    they will still be dicts from the "get" side but we have all the "set" methods raise NotImplementedError.

  2. Log in to comment