[Pyrex] C pointers and arrays again...
Adapted Cat
a.c.junker at gmail.com
Fri Jan 12 05:25:10 UTC 2007
Even though NULL is a reserved word in Pyrex, the generated C
code uses 0. For example:
if ptr == NULL:
...becomes...
__pyx_1 = (__pyx_v_ptr == 0);
Could the NULL be preserved in the C code, please?
Also, it seems that there is no way to declare a C array pre-filled
with directly in Pyrex. I can declare it in a C header, and reference
it with a cdef extern, or if the data can fit into chars, I can declare a
module-level Python list,
and create a C copy at load time as follows:
pydata = [1,2,3,4,5,6, ...]
cdef int *cdata
cdata = pydata
However, this more than doubles the memory taken up, and adds
extra computation time at module load time. What I would like to do
is declare a static array at the module scope natively in Pyrex,
without having to drop down into C, e.g.:
cdef int cdata[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Is there a way to do this?
Thanks
More information about the Pyrex
mailing list