Show More
@@ -1195,12 +1195,12 b' def cachefunc(func):' | |||
|
1195 | 1195 | '''cache the result of function calls''' |
|
1196 | 1196 | # XXX doesn't handle keywords args |
|
1197 | 1197 | if func.__code__.co_argcount == 0: |
|
1198 | cache = [] | |
|
1198 | listcache = [] | |
|
1199 | 1199 | |
|
1200 | 1200 | def f(): |
|
1201 | if len(cache) == 0: | |
|
1202 | cache.append(func()) | |
|
1203 | return cache[0] | |
|
1201 | if len(listcache) == 0: | |
|
1202 | listcache.append(func()) | |
|
1203 | return listcache[0] | |
|
1204 | 1204 | |
|
1205 | 1205 | return f |
|
1206 | 1206 | cache = {} |
General Comments 0
You need to be logged in to leave comments.
Login now