cython def sum_numbers(n): cdef int i, sum = 0 for i in range(n): sum += i return sum cython import numpy as np cimport numpy as np def calculate_mean(arr): cdef double sum = np.sum(arr) cdef int length = arr.shape[0] return sum / length cython cdef class Point: cdef double x, y def __init__(self, x, y): self.x = x self.y = y def distance(self, other): cdef double dx = self.x - other.x cdef double dy = self.y - other.y return (dx * dx + dy * dy) ** 0.5


上一篇:
下一篇:
切换中文