python - Reading and writing an array in a file using C functions in cython -
i instantiating class in cython . want declare 1 of instance array of float values once computing given function , save in binary file using c functions. further call of class if input file exist, instance declared reading array file otherwise compute again. import numpy np cimport numpy np cimport cython libc.stdio cimport file, fopen, fwrite, fscanf, fclose, fseek, seek_end, ftell, stdout, stderr cdef extern "math.h": double exp(double) nogil double log(double) nogil cdef class hit(object): cdef public double[::1] zs, da cdef char* path def __cinit__(self, zs=none, path=none): if path none: raise valueerror("could not find path file contains table of distances") else: self.path=path if zs none: raise valueerror("you must give array contains steps!") self.zs=zs cdef py_ssize_t i, n n=len(self.zs) cdef file *ptr_fr cdef file *ptr_