shanmugh commented on a change in pull request #41: Memoize loader.load and loader.load_json URL: https://github.com/apache/aurora/pull/41#discussion_r222092818
########## File path: src/main/python/apache/aurora/config/loader.py ########## @@ -56,17 +62,49 @@ def flush_schemas(cls): cls.register_schema(base_schema) @classmethod - def load(cls, loadable): - return cls.load_raw(loadable).environment + def gen_content_key(cls, loadable): + key = None + if isinstance(loadable, Compatibility.stringy) and os.path.isfile(loadable): + with open(loadable) as fp: + key = hashlib.md5(fp.read()).hexdigest() + elif hasattr(loadable, 'read') and callable(loadable.read): + key = hashlib.md5(loadable.read()).hexdigest() + loadable.seek(0) + return key Review comment: We will not cache results if `loadable` is from a [Resource](https://github.com/wickman/pystachio/blob/master/pystachio/config.py#L88). Should we use the `loadable` as the key instead? Possible improvement - wonder if we should use the different [ConfigExecutors](https://github.com/wickman/pystachio/blob/master/pystachio/config.py#L148) and call the `matches` function instead of replicating the logic? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services