Skip to content

Commit 9ee078e

Browse files
committed
update comment
1 parent 34f0a56 commit 9ee078e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

unpythonic/syntax/autoref.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,18 @@
3535
# o # --> o
3636
# with autoref(p):
3737
# # the outer autoref just needs to insert its obj to the arglist
38-
# x # --> (lambda _ar314: _ar314[1] if _ar314[0] else x)(*_autoref_resolve((p, o, "x")))
39-
# x.a # --> ((lambda _ar314: _ar314[1] if _ar314[0] else x)(*_autoref_resolve((p, o, "x"))).a
40-
# x[s] # --> ((lambda _ar314: _ar314[1] if _ar314[0] else x)(*_autoref_resolve((p, o, "x")))[s]
38+
# x # --> (lambda _ar314: _ar314[1] if _ar314[0] else x)(_autoref_resolve((p, o, "x")))
39+
# x.a # --> ((lambda _ar314: _ar314[1] if _ar314[0] else x)(_autoref_resolve((p, o, "x"))).a
40+
# x[s] # --> ((lambda _ar314: _ar314[1] if _ar314[0] else x)(_autoref_resolve((p, o, "x")))[s]
4141
# # these are transformed when the **outer** autoref transforms
42-
# o # --> (lambda _ar314: _ar314[1] if _ar314[0] else o)(*_autoref_resolve((p, "o")))
43-
# o.x # --> ((lambda _ar314: _ar314[1] if _ar314[0] else o)(*_autoref_resolve((p, "o")))).x
44-
# o[s] # --> ((lambda _ar314: _ar314[1] if _ar314[0] else o)(*_autoref_resolve((p, "o"))))[s]
42+
# o # --> (lambda _ar314: _ar314[1] if _ar314[0] else o)(_autoref_resolve((p, "o")))
43+
# o.x # --> ((lambda _ar314: _ar314[1] if _ar314[0] else o)(_autoref_resolve((p, "o")))).x
44+
# o[s] # --> ((lambda _ar314: _ar314[1] if _ar314[0] else o)(_autoref_resolve((p, "o"))))[s]
4545
#
46-
# The lambda is needed, because the lexical-variable lookup for ``x`` must occur at the use site.
47-
# We could modify ``_autoref_resolve`` to look in ``locals()``, too (and pass it in), but that
48-
# leads to an unnecessary performance hit.
46+
# The lambda is needed, because the lexical-variable lookup for ``x`` must occur at the use site,
47+
# and it can only be performed by Python itself. We could modify ``_autoref_resolve`` to take
48+
# ``locals()`` and ``globals()`` as arguments and look also in the ``builtins`` module,
49+
# but that way we get no access to the enclosing scopes (the "E" in LEGB).
4950
#
5051
# Recall the blocks expand from inside out. Here ``_ar*`` are gensyms. A single unique name
5152
# for the parameter of the lambdas would be sufficient, but this is easier to arrange.

0 commit comments

Comments
 (0)