简单程序(2 个循环)在使用 CPython 时在 PyPy 中崩溃



这是一个简单的程序,用于解决CodeJam的回收数字(我知道它可以改进)。

它适用于CPython,但在PyPy v1.8中崩溃并显示错误:

RPython traceback:
  File "jit_metainterp_compile.c", line 19477, in send_loop_to_backend
  File "jit_backend_x86_assembler.c", line 2293, in Assembler386_assemble_loop
  File "jit_backend_x86_regalloc.c", line 462, in RegAlloc_prepare_loop
  File "jit_backend_x86_regalloc.c", line 1027, in RegAlloc__prepare
  File "jit_backend_x86_regalloc.c", line 3657, in RegAlloc__compute_vars_longevity
Fatal RPython error: AssertionError
[1]    8440 abort      pypy cj.py

法典:

#!/usr/bin/env python2
def permutations(a,b,x):
    y = str(x)
    cnt = 0
    for i in range(1,len(y)):
        j = int(y[i:]+y[:i])
        if j == x:
            break
        elif j > x and j >= a and j <= b:
            cnt += 1
    return cnt
nc = int(raw_input())
for c in xrange(nc):
    a, b = map(int,raw_input().split())
    cnt = 0
    for i in range(a,b+1):
        cnt += permutations(a,b,i)
    print "Case #%i: %i" % (c+1, cnt)

示例输入:

4
1 9
10 40
100 500
1111 2222

这看起来像一个错误。事实上,它可能与这个错误报告有关:

https://bitbucket.org/pypy/pypy/issues/1075/

每晚尝试最新的。

相关内容

最新更新