Skip to content
Back to top
View this page
Edit this page

# xonsh.codecache

Tools for caching xonsh code.

xonsh.codecache.code_cache_check(cachefname)

  Check whether the code cache for a particular piece of code is valid.

  Returns a tuple containing: a boolean representing whether the cached code should be used, and the cached code (or `None` if the cache should not be used).

xonsh.codecache.code_cache_name(code)

  Return an appropriate spoofed filename for the given code.

xonsh.codecache.compile_code(filename, code, execer, glb, loc, mode)

  Wrapper for `execer.compile` to compile the given code

xonsh.codecache.get_cache_filename(fname, code=True)

  Return the filename of the cache for the given filename.

  Cache filenames are similar to those used by the Mercurial DVCS for its internal store.

  The `code` switch should be true if we should use the code store rather than the script store.

xonsh.codecache.run_code_with_cache(code, display_filename, execer, glb=None, loc=None, mode='exec')

  Run a piece of code, using a cached version if it exists, and updating the cache as necessary. See run_compiled_code for the return value.

xonsh.codecache.run_compiled_code(code, glb, loc, mode)

  Helper to run code in a given mode and context. Returns a sys.exc_info() triplet in case the code raises an exception, or (None, None, None) otherwise.

xonsh.codecache.run_script_with_cache(filename, execer, glb=None, loc=None, mode='exec')

  Run a script, using a cached version if it exists (and the source has not changed), and updating the cache as necessary. See run_compiled_code for the return value.

xonsh.codecache.script_cache_check(filename, cachefname)

  Check whether the script cache for a particular file is valid.

  Returns a tuple containing: a boolean representing whether the cached code should be used, and the cached code (or `None` if the cache should not be used).

xonsh.codecache.should_use_cache(execer, mode)

  Return `True` if caching has been enabled for this mode (through command line flags or environment variables)

xonsh.codecache.update_cache(ccode, cache_file_name)

  Update the cache at `cache_file_name` to contain the compiled code represented by `ccode`.