xonsh.codecache

Tools for caching xonsh code.

xonsh.codecache.code_cache_check(cachefname)[source]

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)[source]

Return an appropriate spoofed filename for the given code.

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

Wrapper for execer.compile to compile the given code

xonsh.codecache.get_cache_filename(fname, code=True)[source]

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')[source]

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)[source]

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')[source]

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)[source]

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)[source]

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)[source]

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