-
-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a completion cache for numpy/tensorflow, fixes #1116
- Loading branch information
1 parent
1cdeee6
commit bf446f2
Showing
5 changed files
with
115 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
_cache = {} | ||
|
||
|
||
def save_entry(module_name, name, cache): | ||
try: | ||
module_cache = _cache[module_name] | ||
except KeyError: | ||
module_cache = _cache[module_name] = {} | ||
module_cache[name] = cache | ||
|
||
|
||
def _create_get_from_cache(number): | ||
def _get_from_cache(module_name, name, get_cache_values): | ||
try: | ||
return _cache[module_name][name][number] | ||
except KeyError: | ||
v = get_cache_values() | ||
save_entry(module_name, name, v) | ||
return v[number] | ||
return _get_from_cache | ||
|
||
|
||
get_type = _create_get_from_cache(0) | ||
get_docstring_signature = _create_get_from_cache(1) | ||
get_docstring = _create_get_from_cache(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters