# HG changeset patch # User Jeremy Thurgood # Date 1302347288 -7200 # Node ID 2258c2a6dbaebf9ed0564c1b4ee40c27e6562154 # Parent 8f578fe33fe7a8c81fb4aebc61bc58955c7ae12e Cache get_files() stuff to avoid unnecessary filesystem operations. diff -r 8f578fe33fe7 -r 2258c2a6dbae skaapsteker/data.py --- a/skaapsteker/data.py Sat Apr 09 13:04:25 2011 +0200 +++ b/skaapsteker/data.py Sat Apr 09 13:08:08 2011 +0200 @@ -33,9 +33,13 @@ return open(filepath(filename), mode) +DIR_LISTS = {} + def get_files(folder): """Return a sorted list of files in the given directory, with the directory stripped""" - return sorted(os.listdir(filepath(folder))) + if folder not in DIR_LISTS: + DIR_LISTS[folder] = sorted(os.listdir(filepath(folder))) + return DIR_LISTS[folder] IMAGES = {}