• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python jit.hint函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pypy.rlib.jit.hint函数的典型用法代码示例。如果您正苦于以下问题:Python hint函数的具体用法?Python hint怎么用?Python hint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了hint函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: on_enter_jit

 def on_enter_jit(self, invariants, reds, bytecode, pos):
     # Now some strange code that makes a copy of the 'args' list in
     # a complicated way...  this is a workaround forcing the whole 'args'
     # list to be virtual.  It is a way to tell the JIT compiler that it
     # doesn't have to worry about the 'args' list being unpredictably
     # modified.
     oldloops = invariants
     oldargs = reds.args
     argcount = promote(len(oldargs))
     args = []
     n = 0
     while n < argcount:
         hint(n, concrete=True)
         args.append(oldargs[n])
         n += 1
     reds.args = args
     # turn the green 'loops' from 'invariants' into a virtual list
     oldloops = hint(oldloops, deepfreeze=True)
     argcount = len(oldloops)
     loops = []
     n = 0
     while n < argcount:
         hint(n, concrete=True)
         loops.append(oldloops[n])
         n += 1
     reds.loops = loops
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:26,代码来源:tiny2_hotpath.py


示例2: f

 def f(x):
     while x > 0:
         myjitdriver.can_enter_jit(x=x)
         myjitdriver.jit_merge_point(x=x)
         a = A()
         hint(a, promote=True)
         x -= 1
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:test_basic.py


示例3: copy_and_basic_unify

 def copy_and_basic_unify(self, other, heap, memo):
     hint(self, concrete=True)
     if isinstance(other, Atom) and (self is other or
                                     other.name == self.name):
         return self
     else:
         raise UnificationFailed
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:7,代码来源:term.py


示例4: call_valuestack

    def call_valuestack(self, w_func, nargs, frame):
        if not self.config.objspace.disable_call_speedhacks:
            # XXX start of hack for performance
            from pypy.interpreter.function import Function, Method
            hint(w_func.__class__, promote=True)
            if isinstance(w_func, Method):
                w_inst = w_func.w_instance
                if w_inst is not None:
                    func = w_func.w_function
                    if isinstance(func, Function):
                        return func.funccall_obj_valuestack(w_inst, nargs, frame)
                elif nargs > 0 and self.is_true(
                    self.abstract_isinstance(frame.peekvalue(nargs-1),   #    :-(
                                             w_func.w_class)):
                    w_func = w_func.w_function

            if isinstance(w_func, Function):
                return w_func.funccall_valuestack(nargs, frame)
            # XXX end of hack for performance

        args = frame.make_arguments(nargs)
        try:
            return self.call_args(w_func, args)
        finally:
            if isinstance(args, ArgumentsFromValuestack):
                args.frame = None
开发者ID:antoine1fr,项目名称:pygirl,代码行数:26,代码来源:baseobjspace.py


示例5: dispatch_jit

    def dispatch_jit(self, pycode, next_instr, ec):
        hint(None, global_merge_point=True)
        pycode = hint(pycode, deepfreeze=True)

        entry_fastlocals_w = self.jit_enter_frame(pycode, next_instr)

        # For the sequel, force 'next_instr' to be unsigned for performance
        next_instr = r_uint(next_instr)
        co_code = pycode.co_code

        try:
            try:
                while True:
                    hint(None, global_merge_point=True)
                    next_instr = self.handle_bytecode(co_code, next_instr, ec)
            except Return:
                w_result = self.popvalue()
                self.blockstack = None
                self.valuestack_w = None
                return w_result
            except Yield:
                w_result = self.popvalue()
                return w_result
        finally:
            self.jit_leave_frame(pycode, entry_fastlocals_w)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:25,代码来源:interp_jit.py


示例6: f

 def f(v):
     hint(None, global_merge_point=True)
     s = S(1, 10)
     v.s = s
     g(v)
     s2 = v.s
     return s.x * 2 + s.y + s2.x * 2 + s2.y
开发者ID:camillobruni,项目名称:pygirl,代码行数:7,代码来源:test_virtualizable.py


示例7: f

 def f(x):
     hint(None, global_merge_point=True)
     lst = g(x)
     try:
         return lst[0]
     except IndexError:
         return -42
开发者ID:antoine1fr,项目名称:pygirl,代码行数:7,代码来源:test_portal.py


示例8: ll_function

 def ll_function(a, i):
     a = hint(a, deepfreeze=True)
     res = a[i]
     res = hint(res, concrete=True)
     
     res = hint(res, variable=True)
     return res
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:7,代码来源:test_annotator.py


示例9: ll_function

 def ll_function(n):
     hint(None, global_merge_point=True)
     s = lltype.malloc(S)
     c = ll_two(n, s)
     k = hint(s.x, promote=True)
     k += c
     return hint(k, variable=True)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:7,代码来源:test_promotion.py


示例10: pushrevvalues

 def pushrevvalues(self, n, values_w): # n should be len(values_w)
     while True:
         n -= 1
         if n < 0:
             break
         hint(n, concrete=True)
         self.pushvalue(values_w[n])
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:7,代码来源:pyframe.py


示例11: ll_three

 def ll_three(s, k):
     k = hint(k, promote=True)
     if s.x > 6:
         k *= hint(s.y, promote=True)
         return k
     else:
         return hint(1, concrete=True)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:7,代码来源:test_promotion.py


示例12: interpret

def interpret(bytecode, args):
    """The interpreter's entry point and portal function.
    """
    loops = []
    stack = empty_stack()
    pos = 0
    while True:
        tinyjitdriver.jit_merge_point(args=args, loops=loops, stack=stack, bytecode=bytecode, pos=pos)
        bytecode = hint(bytecode, deepfreeze=True)
        if pos >= len(bytecode):
            break
        opcode = bytecode[pos]
        hint(opcode, concrete=True)  # same as in tiny1.py
        pos += 1
        if opcode == "ADD":
            stack = op2(stack, func_add_int, func_add_float)
        elif opcode == "SUB":
            stack = op2(stack, func_sub_int, func_sub_float)
        elif opcode == "MUL":
            stack = op2(stack, func_mul_int, func_mul_float)
        elif opcode[0] == "#":
            n = myint(opcode, start=1)
            stack = Stack(args[n - 1], stack)
        elif opcode.startswith("->#"):
            n = myint(opcode, start=3)
            if n > len(args):
                raise IndexError
            stack, args[n - 1] = stack.pop()
        elif opcode == "{":
            loops.append(pos)
        elif opcode == "}":
            stack, flag = stack.pop()
            if flag.as_int() == 0:
                loops.pop()
            else:
                pos = loops[-1]
                # A common problem when interpreting loops or jumps: the 'pos'
                # above is read out of a list, so the hint-annotator thinks
                # it must be red (not a compile-time constant).  But the
                # hint(opcode, concrete=True) in the next iteration of the
                # loop requires all variables the 'opcode' depends on to be
                # green, including this 'pos'.  We promote 'pos' to a green
                # here, as early as possible.  Note that in practice the 'pos'
                # read out of the 'loops' list will be a compile-time constant
                # because it was pushed as a compile-time constant by the '{'
                # case above into 'loops', which is a virtual list, so the
                # promotion below is just a way to make the colors match.
                pos = promote(pos)
                tinyjitdriver.can_enter_jit(args=args, loops=loops, stack=stack, bytecode=bytecode, pos=pos)
        else:
            try:
                try:
                    v = IntBox(int(opcode))
                except ValueError:
                    v = FloatBox(myfloat(opcode))
                stack = Stack(v, stack)
            except ValueError:
                pass  # ignore rest
    return stack
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:59,代码来源:tiny3_hotpath.py


示例13: get

    def get(self, name):
        self = hint(self, promote=True)
        sc_version = hint(self.semiconstant_version, promote=True)

        if self._is_semiconstant(name, sc_version):
            return self._get_semiconstant(name, sc_version)
        else:
            return self._get_intern(name)
开发者ID:agrif,项目名称:lisplisp,代码行数:8,代码来源:scope.py


示例14: set_semiconstant

    def set_semiconstant(self, name, val, local_only=False):
        self = hint(self, promote=True)
        sc_version = hint(self.semiconstant_version, promote=True)

        self._set_intern(name, val, local_only)
        if not self._is_semiconstant(name, sc_version):
            self.semiconstants.append(name)
        self.semiconstant_version = VersionTag()
开发者ID:agrif,项目名称:lisplisp,代码行数:8,代码来源:scope.py


示例15: ll_function

 def ll_function(x):
     mylist = hint(lst, deepfreeze=True)
     try:
         z = mylist[x]
     except IndexError:
         return -42
     hint(z, concrete=True)
     return z
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:8,代码来源:test_vlist.py


示例16: ll_function

 def ll_function(n):
     hint(None, global_merge_point=True)
     k = n
     if k > 5:
         k //= 2
     k = hint(k, promote=True)
     k *= 17
     return hint(k, variable=True)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:8,代码来源:test_portal.py


示例17: f

 def f(n):
     hint(n, concrete=True)
     if n == 0:
         s = "abc"
     else:
         s = "123"
     a = h1(s)
     return a
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:8,代码来源:test_annotator.py


示例18: set

    def set(self, name, val, local_only=False):
        self = hint(self, promote=True)
        sc_version = hint(self.semiconstant_version, promote=True)

        if self._is_semiconstant(name, sc_version):
            self.set_semiconstant(name, val)
        else:
            self._set_intern(name, val, local_only)
开发者ID:agrif,项目名称:lisplisp,代码行数:8,代码来源:scope.py


示例19: get_next_structure

 def get_next_structure(self, key):
     # jit helper
     self = hint(self, promote=True)
     key = hint(key, promote=True)
     newstruct = _get_next_structure_shared(self, key)
     if not we_are_jitted():
         self._size_estimate -= self.size_estimate()
         self._size_estimate += newstruct.size_estimate()
     return newstruct
开发者ID:enyst,项目名称:plexnet,代码行数:9,代码来源:sharingdict.py


示例20: lookup_where_with_method_cache

 def lookup_where_with_method_cache(w_self, name):
     space = w_self.space
     w_self = hint(w_self, promote=True)
     assert space.config.objspace.std.withmethodcache
     version_tag = hint(w_self.version_tag(), promote=True)
     if version_tag is None:
         tup = w_self._lookup_where(name)
         return tup
     return w_self._pure_lookup_where_with_method_cache(name, version_tag)
开发者ID:alkorzt,项目名称:pypy,代码行数:9,代码来源:typeobject.py



注:本文中的pypy.rlib.jit.hint函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python jit.promote函数代码示例发布时间:2022-05-27
下一篇:
Python debug.make_sure_not_resized函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap