Commits

Lynn Rees committed 4862125

- move down here

Comments (0)

Files changed (2)

 
 class lazybase(object):
 
-    '''base for lazy descriptors'''
+    '''Base class for lazy descriptors.'''
 
 
 class _lazyinit(lazybase):
 
-    '''base for lazy descriptors'''
+    '''Base initializer for lazy descriptors.'''
 
     def __init__(self, method, _wrap=update_wrapper):
         super(_lazyinit, self).__init__()
 
 class lazy(_lazyinit):
 
-    '''
-    Lazily assign attributes on an instance upon first use.
-    '''
+    '''Lazily assign attributes on an instance upon first use.'''
 
     def __get__(self, this, that):
         return self if this is None else self._set(this)
 
 class lazypartial(lazy):
 
-    '''
-    Lazily assign attributes on an instance upon first use.
-    '''
+    '''Lazily assign attributes on an instance upon first use.'''
 
     def _set(self, this):
         return setter(this, self.name, partial(*self.method(this)))
 
 class lazy_class(_lazyinit):
 
-    '''
-    Lazily assign attributes on an class upon first use.
-    '''
+    '''Lazily assign attributes on an class upon first use.'''
 
     def __get__(self, this, that):
         return self._set(that)
 
 class lazyset(lazy):
 
-    '''
-    Lazily assign attributes with a custom setter.
-    '''
+    '''Lazily assign attributes with a custom setter.'''
 
     def __init__(self, method, fget=None, _wrap=update_wrapper):
         super(lazyset, self).__init__(method)
 
 
 class bothbase(_lazyinit):
+    
+    '''Base for two-way lazy descriptors.'''
 
     def __init__(self, method, expr=None, _wrap=update_wrapper):
         super(bothbase, self).__init__(method)
 
 class ResetMixin(local):
 
-    '''Reset descriptors subclassing :class:`lazybase`\.'''
+    '''Mixin for reseting descriptors subclassing :class:`lazybase`\.'''
 
     def reset(self):
         '''Reset previously accessed :class:`lazybase` attributes.'''
 lazyload = lambda x: lazyimport(x) if isstring(x) and '.' in x else x
 
 
+def diff(current, past):
+    '''Difference between `past` and `current` ``dicts``.'''
+    intersect = set(current).intersection(set(past))
+    changed = set(o for o in intersect if past[o] != current[o])
+    return dict((k, v) for k, v in items(current) if k in changed)
+
+
 def lazyimport(path, attribute=None, i=import_module, g=getattr, s=isstring):
     '''
     Deferred module loader.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.