class documentation
class AccessVisitor(ast.NodeVisitor): (source)
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 conditionalX 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_ |
Visit an Assign, ordering RHS accesses before LHS accesses. |
Method | visit_ |
Visit an AugAssign, which contains both a read and a write. |
Method | visit_ |
Visit a Name, adding it to the list of accesses. |
Instance Variable | accesses |
List of accesses encountered by the visitor. |