I am now using cython to read an input file, convert the string to int and store them in a c array (instead of a list) to save space. The code I have looks like this:
cdef long p[10000000]
cdef long i
i = 0
f = open(filename, 'r')
for line in f:
temp = map(int, line.split())
p[i] = temp[0]
i = i + 1
f.close()
However, the program is always aborted when I refer to the array p. Somehow the array is not "defined" as the memory usage is very low. It works, however, if I'm doing
cdef i
for i in range(0, 1000):
p[i] = i
My guesses:
p
is allocated on the stack and as soon as the given function returns, access to p
is illegal.i
for overflow, what happens if i > 1000000
?ulimit -a
Overall there is not enough information in the OP, e.g.:
p
in what context?I could not reproduce your problem with Python 2.7.3 Cython 0.17.2 gcc 4.7.2 linux 3.6.9 x86-64
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With