This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7.
If you are looking for an IPython version compatible with Python 2.7, please use the IPython 5.x LTS release and refer to its documentation (LTS is the long term support release).
Compiler tools with improved interactive support.
Provides compilation machinery similar to codeop, but with caching support so we can provide interactive tracebacks.
- class IPython.core.compilerop.CachingCompiler¶
A compiler that caches code compiled from interactive statements.
- 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.
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.
- get_code_name(raw_code, transformed_code, number)¶
Compute filename given the code, and the cell number.
Reset compiler flags to default state.
- IPython.core.compilerop.code_name(code, number=0)¶
Compute a (probably) unique name for code for caching.
This now expects code to be unicode.
Deprecated since IPython 8.6. Call linecache.checkcache() directly.
It was already not necessary to call this function directly. If no CachingCompiler had been created, this function would fail badly. If an instance had been created, this function would’ve been monkeypatched into place.
As of IPython 8.6, the monkeypatching has gone away entirely. But there were still internal callers of this function, so maybe external callers also existed?