Code:
cpdef values(int n):
cdef size_t i
cdef double * v = <double *> malloc(sizeof(double) * n)
if v is NULL:
abort()
for i in range(n):
print v[i]
Output:
>>> values(5)
1.06816855917e-306
0.0
0.0
0.0
0.0
Question:
Why does this function print zeros and where does the leading number come from / what does it mean? I thought unlike calloc
, malloc
does not initialize to zero, as said on wikipedia and in this thread. What is happening here behind the scenes of Python / Cython / C?