Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching choices for choices completer #136

Open
sils opened this issue Jul 13, 2016 · 5 comments
Open

Caching choices for choices completer #136

sils opened this issue Jul 13, 2016 · 5 comments

Comments

@sils
Copy link

sils commented Jul 13, 2016

Hi,

we use argcomplete in coala (coala-analyzer.org) and getting possible values for one of our completers is actually something that takes about .5 seconds on decent systems. It would be nice if argcomplete would have a way to cache completions so that the experience of the user. Possibly you want the ability to mark a completion as not cached if it depends on others e.g.

@kislyuk
Copy link
Owner

kislyuk commented Jul 13, 2016

Thanks for the suggestion. How would you envision this cache working?

@sils
Copy link
Author

sils commented Jul 13, 2016

So this seems only relevant to the ChoicesCompleter to me, it would have an additional __init__ parameter that enables caching. When caching is enabled it is considered cheaper to read the cached choices from a cache than actually calculating them (related: #138, #137 btw.).

Assuming #138 gets merged one could hook up writing and loading to a file (name provided by https://pypi.python.org/pypi/appdirs/ ideally to be platform independent) to the choices setter or the _load_choices function (remove the lambda, put the function in a protected/private member.)

@kislyuk
Copy link
Owner

kislyuk commented Jul 13, 2016

What would the cache key and expiration strategy be?

@sils
Copy link
Author

sils commented Jul 13, 2016

Not sure indeed about this one. The user of the library should definitely be able to influence that behaviour because it'll be tied to his needs.

@kislyuk
Copy link
Owner

kislyuk commented Jul 13, 2016

OK. You're not the first person who requested this :) I'm going to think about this some more. So far I'm leaning toward building caching into CompletionFinder, not Completer, and using the full command line as the key. There are quite a few design chocies to make in how the cache should behave, especially in making sure it doesn't make the completions slower in pathological cases like slow cache I/O.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants