我有以下代码,适当地转换为cython:
from numpy import *
## returns winning players or [] if undecided.
def score(board):
scores = []
checked = zeros(board.shape)
for i in xrange(len(board)):
for j in xrange(len(board)):
if checked[i,j] == 0 and board[i,j] !=0:
... do stuf
Run Code Online (Sandbox Code Playgroud)
我尝试转换为cython:
import numpy as np
cimport numpy as np
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.nonecheck(False)
## returns winning players or [] if undecided.
def score(np.ndarray[int, ndim=2] board):
scores = []
cdef np.ndarray[int, ndim = 2 ] checked
checked = np.zeros(board.shape)
for i in xrange(len(board)): …Run Code Online (Sandbox Code Playgroud)