Commit 38747f50 authored by Yannick Roehlly's avatar Yannick Roehlly
Browse files

Implement module caching in the warehouse

parent 05d6c303
......@@ -33,6 +33,37 @@ class SedWarehouse(object): = SedStore()
# Cache for modules
self.module_cache = {}
def get_module_cached(self, name, **kwargs):
"""Get the SED module using the internal cache.
name : string
Module name.
The other keyworded parameters are the module parameters.
a pcigale.sed.modules.Module instance
# JSon representation of the tuple (name, parameters) used as a key
# for storing the module in the cache.
encoder = JSONEncoder()
module_key = encoder.encode((name, kwargs))
if module_key in self.module_cache:
module = self.module_cache[module_key]
module = sed_modules.get_module(name, **kwargs)
self.module_cache[module_key] = module
return module
def get_sed(self, module_list, parameter_list):
"""Get the SED corresponding to the module and parameter lists
......@@ -66,7 +97,7 @@ class SedWarehouse(object):
sed =
if not sed:
mod = sed_modules.get_module(module_list.pop(),
mod = self.get_module_cached(module_list.pop(),
if (len(module_list) == 0):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment