本文整理汇总了Python中pypy.translator.interactive.Translation.viewcg方法的典型用法代码示例。如果您正苦于以下问题:Python Translation.viewcg方法的具体用法?Python Translation.viewcg怎么用?Python Translation.viewcg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.translator.interactive.Translation
的用法示例。
在下文中一共展示了Translation.viewcg方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _makefunc_str_int
# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import viewcg [as 别名]
def _makefunc_str_int(cls, f):
def main(argv):
arg0 = argv[1]
arg1 = int(argv[2])
try:
res = f(arg0, arg1)
except MemoryError:
print "MEMORY-ERROR"
else:
print res
return 0
t = Translation(main, standalone=True, gc=cls.gcpolicy,
policy=annpolicy.StrictAnnotatorPolicy(),
taggedpointers=cls.taggedpointers,
gcremovetypeptr=cls.removetypeptr)
t.disable(['backendopt'])
t.set_backend_extra_options(c_debug_defines=True)
t.rtype()
if conftest.option.view:
t.viewcg()
exename = t.compile()
def run(s, i):
data = py.process.cmdexec("%s %s %d" % (exename, s, i))
data = data.strip()
if data == 'MEMORY-ERROR':
raise MemoryError
return data
return run
示例2: NN
# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import viewcg [as 别名]
n = NN(2, 3, 1)
# train it with some patterns
n.train(pat, 2000)
# test it
n.test(pat)
if __name__ == '__main__':
print 'Loading...'
from pypy.translator.interactive import Translation
t = Translation(demo)
print 'Annotating...'
t.annotate([])
t.viewcg()
print 'Specializing...'
t.rtype() # enable this to see (some) lower-level Cish operations
print 'Compiling...'
f = t.compile_c()
print 'Running...'
T = time.time()
for i in range(10):
f()
t1 = time.time() - T
print "that took", t1
T = time.time()
示例3: test_annotated
# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import viewcg [as 别名]
def test_annotated():
from pypy.translator.interactive import Translation
t = Translation(is_prime)
t.annotate([int])
t.viewcg()