def _import_wrapper(level, fromlist, name, *, _getframe=sys._getframe): calling_frame = _getframe(1) return thunk( __import__, name, calling_frame.f_globals, calling_frame.f_locals, fromlist, level, )
def _start_dict_comprehension(self, instr, *instrs): yield instructions.LOAD_CONST(thunk(dict)).steal(instr) # TOS = thunk(dict) yield instructions.STORE_FAST('__comp_accumulator__') *body, map_add = instrs yield from self.patterndispatcher(body) # TOS = k # TOS1 = v yield instructions.LOAD_FAST('__comp_accumulator__').steal(map_add) # TOS = __map__ # TOS1 = k # TOS2 = v yield instructions.ROT_TWO() # TOS = k # TOS1 = __map__ # TOS2 = v yield instructions.STORE_SUBSCR() self.begin(IN_COMPREHENSION)
def _lazy_is(a, b, *, is_=is_): return thunk(is_, a, b)
def _lazy_not(a, *, not_=not_): return thunk(not_, a)
def _build_map(self, instr): yield instructions.LOAD_CONST(thunk(dict)).steal(instr) # TOS = m = thunk(dict) yield from (instructions.DUP_TOP(),) * instr.arg