当前位置: 首页>>代码示例>>Python>>正文


Python WarmEnterState._make_jitcell_getter_custom方法代码示例

本文整理汇总了Python中pypy.jit.metainterp.warmstate.WarmEnterState._make_jitcell_getter_custom方法的典型用法代码示例。如果您正苦于以下问题:Python WarmEnterState._make_jitcell_getter_custom方法的具体用法?Python WarmEnterState._make_jitcell_getter_custom怎么用?Python WarmEnterState._make_jitcell_getter_custom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pypy.jit.metainterp.warmstate.WarmEnterState的用法示例。


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

示例1: test_make_jitcell_getter_custom

# 需要导入模块: from pypy.jit.metainterp.warmstate import WarmEnterState [as 别名]
# 或者: from pypy.jit.metainterp.warmstate.WarmEnterState import _make_jitcell_getter_custom [as 别名]
def test_make_jitcell_getter_custom():
    from pypy.rpython.typesystem import LowLevelTypeSystem
    class FakeRTyper:
        type_system = LowLevelTypeSystem.instance
    class FakeJitCell(BaseJitCell):
        pass
    celldict = {}
    def getter(x, y):
        return celldict.get((x, y))
    def setter(newcell, x, y):
        newcell.x = x
        newcell.y = y
        celldict[x, y] = newcell
    GETTER = lltype.Ptr(lltype.FuncType([lltype.Signed, lltype.Float],
                                        llmemory.GCREF))
    SETTER = lltype.Ptr(lltype.FuncType([llmemory.GCREF, lltype.Signed,
                                         lltype.Float], lltype.Void))
    class FakeWarmRunnerDesc:
        rtyper = FakeRTyper()
        cpu = None
        get_jitcell_at_ptr = llhelper(GETTER, getter)
        set_jitcell_at_ptr = llhelper(SETTER, setter)
    #
    state = WarmEnterState(FakeWarmRunnerDesc())
    get_jitcell = state._make_jitcell_getter_custom(FakeJitCell)
    cell1 = get_jitcell(5, 42.5)
    assert isinstance(cell1, FakeJitCell)
    assert cell1.x == 5
    assert cell1.y == 42.5
    cell2 = get_jitcell(5, 42.5)
    assert cell2 is cell1
    cell3 = get_jitcell(41, 42.5)
    cell4 = get_jitcell(42, 0.25)
    assert cell1 is not cell3 is not cell4 is not cell1
开发者ID:alkorzt,项目名称:pypy,代码行数:36,代码来源:test_warmstate.py


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