Skip to content

Commit

Permalink
cache values for find_packages and find_distributions, just on a hunch
Browse files Browse the repository at this point in the history
  • Loading branch information
ejucovy committed Apr 10, 2009
1 parent bcc5c9b commit c2b4464
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/z3c/autoinclude/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,14 @@ def find_packages(where='.', exclude=()):
from fnmatch import fnmatchcase
out = [item for item in out if not fnmatchcase(item,pat)]
return out

def cached(func):
cache = {}
def inner(*args):
if (func, args) not in cache:
cache[(func, args)] = list(func(*args)) #guard against generators
return cache[(func, args)]
return inner

find_packages = cached(find_packages)
find_distributions = cached(find_distributions)

0 comments on commit c2b4464

Please sign in to comment.