class documentation

class AccessVisitor(ast.NodeVisitor): (source)

View In Hierarchy

Visitor that computes an ordered list of accesses.

Accesses are ordered based on a depth-first traversal of the AST, using the order of fields defined in gast, except for Assign nodes, for which the RHS is ordered before the LHS.

This may differ from Python execution semantics in two ways:

  • Both branches sides of short-circuit and/or expressions or conditional X if Y else Z expressions are considered to be evaluated, even if one of them is actually skipped at runtime.
  • For AST nodes whose field order doesn't match the Python interpreter's evaluation order, the field order is used instead. Most AST nodes match execution order, but some differ (e.g. for dictionary literals, the interpreter alternates evaluating keys and values, but the field order has all keys and then all values). Assignments are a special case; the AccessVisitor evaluates the RHS first even though the LHS occurs first in the expression.
Method __init__ Undocumented
Method visit_Assign Visit an Assign, ordering RHS accesses before LHS accesses.
Method visit_AugAssign Visit an AugAssign, which contains both a read and a write.
Method visit_Name Visit a Name, adding it to the list of accesses.
Instance Variable accesses List of accesses encountered by the visitor.
def __init__(self): (source)

Undocumented

def visit_Assign(self, node): (source)

Visit an Assign, ordering RHS accesses before LHS accesses.

def visit_AugAssign(self, node): (source)

Visit an AugAssign, which contains both a read and a write.

def visit_Name(self, node): (source)

Visit a Name, adding it to the list of accesses.

accesses: list = (source)

List of accesses encountered by the visitor.