Skip to content

Instantly share code, notes, and snippets.

@fluffybeing
Created March 24, 2014 16:30
Show Gist options
  • Save fluffybeing/9743840 to your computer and use it in GitHub Desktop.
Save fluffybeing/9743840 to your computer and use it in GitHub Desktop.
conversation
<Jc2k> does parinx cache anything? the thought of constantly parsing docstrings in an app isnt a pleasant one.
* rocker has quit (Ping timeout: 246 seconds)
<rahulrrixe> Jc2k : I didn't notice the message early :(
<Jc2k> its ok :)
<rahulrrixe> Jc2k : no there is no caching in parinx
<rahulrrixe> can you suggest me how can i implement this feature
<Jc2k> rahulrrixe: perhaps if you had a Parser class so that the API looked like this:
<Jc2k> from parinx.parser import Parser
<Jc2k> parser = Parser()
<Jc2k> p.get_method_docstring(a_method)
<Jc2k> the parser object would have a self.cache = {}
<Jc2k> methods and objects can (irrc) be used as dictionary keys
<Jc2k> so get_method_docstring(method) could be:
<Jc2k> def get_method_docstring(self, method):
<Jc2k> if method in self.cache:
<Jc2k> return self.cache[method]
<Jc2k> # otherwise parse docstring and then
<Jc2k> self.cache[method] =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment