okcli icon indicating copy to clipboard operation
okcli copied to clipboard

[wip][feat] completion cache, but very much just a PoC right now

Open mriehl opened this issue 5 years ago • 1 comments

Hi,

As discussed #6 here's a draft at completion caching. Definitely don't merge it for now.

Want to get some early feedback since I haven't written python in a while. I've just implemented the config file switch for now, it might actually be good enough because IMHO there's no significant downside to activating the completion cache always. If fetching the completions is fast you won't notice and if it's not you want the cache :stuck_out_tongue:

The usage of pickle might be debatable, since it can be used to execute malicious code (some other thing could tamper with the cache, but then your machine is already compromised, etc). Pickle has the advantage that it just works on python platforms and it doesn't care about the structure of the completer.

I've also just tested this by setting the pythonpath and running it locally. setup.py test tries to build a wheel and fails for some reason, and I haven't found instructions on how to run the existing tests, but I'm partial to adding some.

Other stuff I'm not sure about:

  • does it make sense to change the "refreshing completions..." output? I'm not sure.
  • more error handling to be sure in case something blows up (e.G. user corrupts the pickled file)

mriehl avatar Sep 03 '20 13:09 mriehl

Thanks for the review @cboddy ! Will look into making the suggested changes as soon as I have some breathing room!

mriehl avatar Sep 28 '20 06:09 mriehl