MCPcopy Index your code
hub / github.com/python/cpython / lazycache

Function lazycache

Lib/linecache.py:200–221  ·  view source on GitHub ↗

Seed the cache for filename with module_globals. The module loader will be asked for the source only when getlines is called, not immediately. If there is an entry in the cache already, it is not altered. :return: True if a lazy load is registered in the cache, otherwise F

(filename, module_globals)

Source from the content-addressed store, hash-verified

198
199
200def lazycache(filename, module_globals):
201 """Seed the cache for filename with module_globals.
202
203 The module loader will be asked for the source only when getlines is
204 called, not immediately.
205
206 If there is an entry in the cache already, it is not altered.
207
208 :return: True if a lazy load is registered in the cache,
209 otherwise False. To register such a load a module loader with a
210 get_source method must be found, the filename must be a cacheable
211 filename, and the filename must not be already cached.
212 """
213 entry = cache.get(filename, None)
214 if entry is not None:
215 return len(entry) == 1
216
217 lazy_entry = _make_lazycache_entry(filename, module_globals)
218 if lazy_entry is not None:
219 cache[filename] = lazy_entry
220 return True
221 return False
222
223
224def _make_lazycache_entry(filename, module_globals):

Callers

nothing calls this directly

Calls 2

_make_lazycache_entryFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…