File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616import operator
1717
1818from .dynassign import dyn , make_dynvar
19+ from .symbol import gensym
1920
2021make_dynvar (resolve_bindings_tuplify = False )
2122
2223try : # Python 3.5+
2324 from operator import matmul , imatmul
2425except ImportError :
25- NoSuchBuiltin = object ( )
26+ NoSuchBuiltin = gensym ( "NoSuchBuiltin" )
2627 matmul = imatmul = NoSuchBuiltin
2728
2829class UnknownArity (ValueError ):
@@ -379,7 +380,7 @@ def f(a):
379380
380381 # https://docs.python.org/3/reference/compound_stmts.html#function-definitions
381382 # https://docs.python.org/3/reference/expressions.html#calls
382- unassigned = object () # gensym
383+ unassigned = object () # gensym("unassigned"), but object() is much faster and we don't need the label.
383384 slots = [unassigned for _ in range (len (params ))] # yes, varparams too
384385
385386 # fill from positional arguments
Original file line number Diff line number Diff line change 3131from functools import wraps
3232
3333from .regutil import register_decorator
34+ # from .symbol import gensym
3435
3536def escape (value , tag = None , allow_catchall = True ):
3637 """Alias for `throw`, for backward compatibility.
@@ -263,7 +264,7 @@ def inner():
263264 Similar usage is valid for named functions, too.
264265 """
265266 # Create a process-wide unique id to tag the ec:
266- anchor = object ()
267+ anchor = object () # gensym("anchor"), but object() is much faster and we don't need the label.
267268 uid = id (anchor )
268269 # Closure property important here. "ec" itself lives as long as someone
269270 # retains a reference to it. It's a first-class value; the callee could
Original file line number Diff line number Diff line change 99
1010from .regutil import register_decorator
1111from .dynassign import make_dynvar
12+ from .symbol import gensym
1213
1314# HACK: break dependency loop llist -> fun -> lazyutil -> collections -> llist
1415#from .collections import mogrify
1516_init_done = False
16- jump = object () # gensym, nothing else "is" this
17+ jump = gensym ( "jump" )
1718def _init_module (): # called by unpythonic.__init__ when otherwise done
1819 global mogrify , jump , _init_done
1920 from .collections import mogrify
Original file line number Diff line number Diff line change 1212from .fold import foldr , foldl
1313from .it import rev
1414from .singleton import Singleton
15+ # from .symbol import gensym
1516
1617# explicit list better for tooling support
1718_exports = ["cons" , "nil" ,
@@ -250,7 +251,7 @@ def __eq__(self, other):
250251 if isinstance (other , cons ):
251252 try : # duck test linked lists
252253 ia , ib = (LinkedListIterator (x ) for x in (self , other ))
253- fill = object () # essentially gensym
254+ fill = object () # gensym("fill"), but object() is much faster and we don't need the label.
254255 for a , b in zip_longest (ia , ib , fillvalue = fill ):
255256 if a != b :
256257 return False
Original file line number Diff line number Diff line change 145145
146146from ..collections import ThreadLocalBox , Shim
147147from ..misc import async_raise , namelambda
148+ from ..symbol import sym
148149
149150from .util import ReuseAddrThreadingTCPServer , socketsource
150151from .msg import MessageDecoder
@@ -228,7 +229,9 @@ def halt(doit=True):
228229 server_print (msg )
229230
230231_bg_results = {}
231- _bg_running , _bg_success , _bg_fail = [object () for _ in range (3 )]
232+ _bg_running = sym ("_bg_running" )
233+ _bg_success = sym ("_bg_success" )
234+ _bg_fail = sym ("bg_fail" )
232235def bg (thunk ):
233236 """Spawn a thread to run `thunk` in the background. Return the thread object.
234237
You can’t perform that action at this time.
0 commit comments