本文整理汇总了Python中pypy.rpython.annlowlevel.llstr函数的典型用法代码示例。如果您正苦于以下问题:Python llstr函数的具体用法?Python llstr怎么用?Python llstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了llstr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_streq_checknull_char
def test_streq_checknull_char():
func = LLtypeHelpers._ll_2_str_eq_checknull_char.im_func
assert func(llstr("wor"), "x") == False
assert func(llstr("w"), "x") == False
assert func(llstr(""), "x") == False
assert func(llstr("x"), "x") == True
assert func(llstr(None), "x") == False
示例2: test_streq_nonnull_char
def test_streq_nonnull_char():
func = LLtypeHelpers._ll_2_str_eq_nonnull_char.im_func
assert func(llstr("wor"), "x") == False
assert func(llstr("w"), "x") == False
assert func(llstr(""), "x") == False
assert func(llstr("x"), "x") == True
py.test.raises(AttributeError, func, llstr(None), "x")
示例3: test_set_param_enable_opts
def test_set_param_enable_opts(self):
from pypy.rpython.annlowlevel import llstr, hlstr
myjitdriver = JitDriver(greens = [], reds = ['n'])
class A(object):
def m(self, n):
return n-1
def g(n):
while n > 0:
myjitdriver.can_enter_jit(n=n)
myjitdriver.jit_merge_point(n=n)
n = A().m(n)
return n
def f(n, enable_opts):
myjitdriver.set_param('enable_opts', hlstr(enable_opts))
return g(n)
# check that the set_param will override the default
res = self.meta_interp(f, [10, llstr('')])
assert res == 0
self.check_loops(new_with_vtable=1)
res = self.meta_interp(f, [10, llstr(ALL_OPTS_NAMES)],
enable_opts='')
assert res == 0
self.check_loops(new_with_vtable=0)
示例4: test_simple
def test_simple(self):
sb = StringBuilderRepr.ll_new(3)
StringBuilderRepr.ll_append_char(sb, 'x')
StringBuilderRepr.ll_append(sb, llstr("abc"))
StringBuilderRepr.ll_append_slice(sb, llstr("foobar"), 2, 5)
StringBuilderRepr.ll_append_multiple_char(sb, 'y', 3)
s = StringBuilderRepr.ll_build(sb)
assert hlstr(s) == "xabcobayyy"
示例5: test_streq_slice_nonnull
def test_streq_slice_nonnull():
p1 = llstr("hello world")
p2 = llstr("wor")
func = LLtypeHelpers._ll_4_str_eq_slice_nonnull.im_func
assert func(p1, 6, 3, p2) == True
assert func(p1, 6, 2, p2) == False
assert func(p1, 5, 3, p2) == False
py.test.raises(AttributeError, func, p1, 2, 1, llstr(None))
示例6: test_streq_slice_checknull
def test_streq_slice_checknull():
p1 = llstr("hello world")
p2 = llstr("wor")
func = LLtypeHelpers._ll_4_str_eq_slice_checknull.im_func
assert func(p1, 6, 3, p2) == True
assert func(p1, 6, 2, p2) == False
assert func(p1, 5, 3, p2) == False
assert func(p1, 2, 1, llstr(None)) == False
示例7: getvar
def getvar(self, arg):
if not arg:
return ConstInt(0)
try:
return ConstInt(int(arg))
except ValueError:
if self.is_float(arg):
return ConstFloat(float(arg))
if arg.startswith('"') or arg.startswith("'"):
# XXX ootype
info = arg.strip("'\"")
return ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF,
llstr(info)))
if arg.startswith('ConstClass('):
name = arg[len('ConstClass('):-1]
return self.get_const(name, 'class')
elif arg == 'None':
return None
elif arg == 'NULL':
if self.type_system == 'lltype':
return ConstPtr(ConstPtr.value)
else:
return ConstObj(ConstObj.value)
elif arg.startswith('ConstPtr('):
name = arg[len('ConstPtr('):-1]
return self.get_const(name, 'ptr')
return self.vars[arg]
示例8: test_streq_slice_char
def test_streq_slice_char():
p1 = llstr("hello world")
func = LLtypeHelpers._ll_4_str_eq_slice_char.im_func
assert func(p1, 6, 3, "w") == False
assert func(p1, 6, 0, "w") == False
assert func(p1, 6, 1, "w") == True
assert func(p1, 6, 1, "x") == False
示例9: read_code
def read_code():
from pypy.module.marshal.interp_marshal import dumps
filename = 'pypyjit_demo.py'
source = readfile(filename)
ec = space.getexecutioncontext()
code = ec.compiler.compile(source, filename, 'exec', 0)
return llstr(space.str_w(dumps(space, code, space.wrap(2))))
示例10: apply_jit
def apply_jit(policy, interp, graph, CPUClass):
print 'warmspot.jittify_and_run() started...'
option.view = True
LIST = graph.getargs()[0].concretetype
lst = LIST.TO.ll_newlist(len(ARGS))
for i, arg in enumerate(ARGS):
lst.ll_setitem_fast(i, llstr(arg))
warmspot.jittify_and_run(interp, graph, [lst], policy=policy,
listops=True, CPUClass=CPUClass,
backendopt=True, inline=True,
optimizer=OPTIMIZER_FULL)
示例11: test_streq_nonnull
def test_streq_nonnull():
p1 = llstr("wor")
p2 = llstr("wor")
assert p1 != p2
func = LLtypeHelpers._ll_2_str_eq_nonnull.im_func
assert func(p1, p1) == True
assert func(p1, p2) == True
assert func(p1, llstr("wrl")) == False
assert func(p1, llstr("world")) == False
assert func(p1, llstr("w")) == False
py.test.raises(AttributeError, func, p1, llstr(None))
py.test.raises(AttributeError, func, llstr(None), p2)
示例12: ll_float_str
def ll_float_str(repr, f):
from pypy.rlib.rfloat import formatd
return llstr(formatd(f, 'f', 6))
示例13: f
def f(arg):
s = llstr(hlstr(arg))
return len(s.chars)
示例14: ll_float_str
def ll_float_str(repr, f):
return llstr(formatd("%f", f))
示例15: test_llstr
def test_llstr(self):
s = llstr("abc")
assert len(s.chars) == 3
assert s.chars[0] == "a"
assert s.chars[1] == "b"
assert s.chars[2] == "c"