- Timestamp:
- 05/25/13 16:19:21 (3 years ago)
- Location:
- branches/decorate
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/decorate/cache.py
r661 r662 9 9 from threading import RLock 10 10 from cache_helper import _CacheInfo, Counter, hashmap as _keymap 11 from INF_cache import inf_cache12 from NO_cache import no_cache13 11 14 12 -
branches/decorate/cache_helper.py
r660 r662 12 12 typed = False, 13 13 kwd_mark = (object(),), #XXX: 'nicer' kwd_mark = ("",) ? None ? 14 flat = True, #XXX: if not flat, then key = (args, tuple) 14 15 fasttypes = set((int, str, frozenset, type(None))), 15 16 sorted=sorted, tuple=tuple, type=type, len=len): 16 17 'Make a cache key from optionally typed positional and keyword arguments' 18 if not flat: 19 key = (args, kwds) #XXX: pickles larger, but is simpler to unpack 20 if typed: 21 sorted_items = sorted(kwds.items()) 22 key += (tuple(type(v) for v in args), \ 23 tuple(type(v) for k, v in sorted_items)) 24 return key 17 25 key = args 18 26 if kwds: … … 21 29 for item in sorted_items: 22 30 key += item 23 if typed: 24 key += tuple(type(v) for v in args)31 if typed: #XXX: 'kwd_mark' between each of the 4 parts, so easy to split 32 key += kwd_mark + tuple(type(v) for v in args) 25 33 if kwds: 26 key += tuple(type(v) for k, v in sorted_items)34 key += kwd_mark + tuple(type(v) for k, v in sorted_items) 27 35 elif len(key) == 1 and type(key[0]) in fasttypes: 28 36 return key[0] -
branches/decorate/memoize.py
r660 r662 353 353 if memo is None: memo = archive_dict() 354 354 elif type(memo) is dict: memo = archive_dict(memo) 355 # does archive make sense with databas , file, ?... (requires more thought)355 # does archive make sense with database, file, ?... (requires more thought) 356 356 357 357 if deep: rounded = deep_round
Note: See TracChangeset
for help on using the changeset viewer.