In rare cases, the current AST rewriting strategy can break functions which violate referential transparency. For example, patsy's formula evaluation magic breaks because it inspects the local namespace of the previous frame in the call stack.
The reason is that rewriting the function call f(x,y) to
trace(f, x, y)
(see #13) changes the observed call stack. Instead, we should rewrite f(x,y) to
In rare cases, the current AST rewriting strategy can break functions which violate referential transparency. For example, patsy's formula evaluation magic breaks because it inspects the local namespace of the previous frame in the call stack.
The reason is that rewriting the function call
f(x,y)
to(see #13) changes the observed call stack. Instead, we should rewrite
f(x,y)
towhich, in view of Python's left-to-right evaluation order, will evaluate as
This will slightly complicate the tracing machinery but will better preserve the call stack. In particular, it should fix the problem with patsy.