[ENH] Speed up first completion#399
Conversation
a411b33 to
0bbb60c
Compare
27b31c0 to
d5e5f7b
Compare
e8970c5 to
18a9101
Compare
|
During installation I encountered an error coming from if licence_ and license.file:
^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'file'. Did you mean: 'title'?It looks like the I believe a lower bound on required mesonpy would be needed, or change in More details:
|
1c3f07b to
d61b636
Compare
232dc63 to
c9a467c
Compare
|
Note that due to the additional log messages this breaks some tests which check ipython output. I'll address these if the performance gains here are sufficient to warrant this change. |
ff1cbc9 to
7a45d5b
Compare
cbce19a to
e81442d
Compare
This reverts commit ee751d3.
| appdirs.user_cache_dir(appname='pyflyby', appauthor=False) | ||
| ).iterdir(): | ||
| _remove_import_cache_dir(path) | ||
| _fast_iter_modules() |
There was a problem hiding this comment.
@peytondmurray do you remember if this is a leftover from local testing ? I can't find any use of this.
There was a problem hiding this comment.
It's been a while since I've touched this, but it's possible that the request for import caching also included a way to rebuild the import cache manually. If it's not being used anywhere, I think it's probably fine to remove it.
There was a problem hiding this comment.
Yes, I think this is the relevant context:
Of course for cases where file contents were modified but no files were added or removed, this wouldn't regenerate the cache like we'd really like. But this may be an edge case that we can handle by adding a function to manually regenerate the cache anyway.
So, this function is probably needed for manually refreshing cache as an escape hatch and should be documented/exposed in public API (or removed if this is rare corner case)
This PR speeds up the first completion by
os.scandir,os.path.basename, andinspect.getmodulenameon every directory entry.<user cache dir>/pyflyby/. Any subsequent completions (including in other ipython sessions) check the mtime of the path, and look for a corresponding file in<user cache dir>/pyflyby/. If a valid cache file is found, module names used for completion are read from the file rather than from the filesystem. Otherwise, the cache is rebuilt.pyflyby.rebuild_import_cache.Other changes:
meson-python>=0.18.0etc/andlibexec/are now placed in<site-packages>/pyflybyinstead of polluting other parts of the filesystem.I also removed some unused python 2 compatibility stuff adjacent to the code I was working on - if it's better to leave this for another PR I'll revert it.
appdirsandprompt_toolkitare now dependencies ofpyflyby.Closes #571.