Permalink
Browse files

memoize wrapped function in _AsyncWrapper

  • Loading branch information...
1 parent 72a1e96 commit a323af37bc51d35faaf8ba0f9f59a0d1dbea8a03 @evilkost committed Apr 13, 2011
Showing with 4 additions and 1 deletion.
  1. +4 −1 brukva/client.py
View
@@ -225,9 +225,12 @@ def reply_ttl(r, *args, **kwargs):
class _AsyncWrapper(object):
def __init__(self, obj):
self.obj = obj
+ self.memoized = {}
def __getattr__(self, item):
- return async(getattr(self.obj, item), cbname='callbacks')
+ if item not in self.memoized:
+ self.memoized[item] = async(getattr(self.obj, item), cbname='callbacks')
+ return self.memoized[item]
class Client(object):

0 comments on commit a323af3

Please sign in to comment.