def getcode(self): # if the self is a compile time constant and if its code # is a BuiltinCode => grab and return its code as a constant if _is_early_constant(self): from pypy.interpreter.gateway import BuiltinCode code = hint(self, deepfreeze=True).code if not isinstance(code, BuiltinCode): code = self.code else: code = self.code return code
def myint(s, start=0): if _is_early_constant(s): s = hint(s, promote=True) start = hint(start, promote=True) n = myint_internal(s, start) if n < 0: raise ValueError else: n = myint_internal(s, start) if n < 0: raise ValueError return n
def f(x): if jit._is_early_constant(x): return 42 return 0
def g(x): if _is_early_constant(x): return 42 hint(x, concrete=True) return 0