Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
# Cython: save as compute.pyx def fast_sum(list[double] data) -> double: cdef double total = 0 cdef int i for i in range(len(data)): total += data[i] return total # compile: python setup.py build_ext --inplace # ctypes: call existing C library from ctypes import CDLL, c_double libm = CDLL("libm.so.6") libm.sqrt.restype = c_double print(libm.sqrt(c_double(16.0))) # 4.0
Result
Open