Module: core.compilerop
Compiler tools with improved interactive support.
Provides compilation machinery similar to codeop, but with caching support so we can provide interactive tracebacks.
1 Class
- class IPython.core.compilerop.CachingCompiler
Bases:
CompileA compiler that caches code compiled from interactive statements.
- __init__()
- ast_parse(source, filename='<unknown>', symbol='exec')
Parse code to an AST with the current compiler flags active.
Arguments are exactly the same as ast.parse (in the standard library), and are passed to the built-in compile function.
- cache(transformed_code, number=0, raw_code=None)
Make a name for a block of code, and cache the code.
- Parameters:
- Returns:
The name of the cached code (as a string). Pass this as the filename
argument to compilation, so that tracebacks are correctly hooked up.
- property compiler_flags
Flags currently active in the compilation process.
- format_code_name(name) str
Return a user-friendly label and name for a code block.
- Parameters:
name (str) – The name for the code block returned from get_code_name
- Return type:
A (label, name) pair that can be used in tracebacks, or None if the default formatting should be used.
- get_code_name(raw_code, transformed_code, number)
Compute filename given the code, and the cell number.
- reset_compiler_flags()
Reset compiler flags to default state.