Rendering API Reference

class numba_scfg.rendering.rendering.BaseRenderer

Base Renderer class.

This is the base class for all types of graph renderers. It defines two methods render_block and render_edges that define how the blocks and edges of the graph are rendered respectively.

render_block(digraph: Digraph, name: str, block: BasicBlock) None

Function that defines how the BasicBlocks in a graph should be rendered.

Parameters:
  • digraph (Digraph) – The graphviz Digraph object that represents the graph/subgraph upon which the current blocks are to be rendered.

  • name (str) – Name of the block to be rendered.

  • block (BasicBlock) – The BasicBlock to be rendered.

render_edges(scfg: SCFG) None

Function that renders the edges in an SCFG.

Parameters:

scfg (SCFG) – The graph whose edges are to be rendered.

class numba_scfg.rendering.rendering.ByteFlowRenderer

The ByteFlowRenderer class is used to render the visual representation of a ByteFlow object.

g

The graphviz Digraph object that represents the entire graph upon which the current ByteFlow is to be rendered.

Type:

Digraph

bcmap

Mapping of bytecode offset to instruction.

Type:

Dict[int, dis.Instruction]

render_byteflow(byteflow: ByteFlow) Digraph

Renders the provided ByteFlow object.

class numba_scfg.rendering.rendering.SCFGRenderer(scfg: SCFG)

The SCFGRenderer class is used to render the visual representation of a SCFG object.

g

The graphviz Digraph object that represents the entire graph upon which the current SCFG is to be rendered.

Type:

Digraph

render_scfg() Digraph

Return the graphviz Digraph that contains the rendered SCFG.

view(name: str | None = None) None

Method used to view the current SCFG as an external graphviz generated PDF file.

Parameters:

name (str) – Name to be given to the external graphviz generated PDF file.

numba_scfg.rendering.rendering.render_flow(flow: ByteFlow) None

Renders multiple ByteFlow representations across various SCFG transformations.

The render_flow` function takes a flow parameter as the ByteFlow to be transformed and rendered and performs the following operations:

  • Renders the pure ByteFlow representation of the function using ByteFlowRenderer and displays it as a document named “before”.

  • Joins the return blocks in the ByteFlow object graph and renders the graph, displaying it as a document named “closed”.

  • Restructures the loops recursively in the ByteFlow object graph and renders the graph, displaying it as named “loop restructured”.

  • Restructures the branch recursively in the ByteFlow object graph and renders the graph, displaying it as named “branch restructured”.

Parameters:

flow (ByteFlow) – The ByteFlow object to be trnasformed and rendered.

numba_scfg.rendering.rendering.render_func(func) None

The render_func` function takes a func parameter as the Python function to be transformed and rendered and renders the byte flow representation of the bytecode of the function.

Parameters:

func (Python function) – The Python function for which bytecode is to be rendered.

numba_scfg.rendering.rendering.render_scfg(scfg: SCFG) None

The render_scfg function takes a scfg parameter as the SCFG object to be transformed and rendered and renders the graphviz representation of the SCFG.

Parameters:

scfg (SCFG) – The structured control flow graph (SCFG) to be rendered.