Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (22 sloc) 0.739 kb
from libc.stdlib cimport malloc, free
cimport cython
from cython.view cimport array
cdef void callback(void *data):
print "callback called"
def create_array(shape, mode, use_callback=False):
cdef array result = array(shape, itemsize=sizeof(int),
format='i', mode=mode)
cdef int *data = <int *>
cdef int i, j, cidx, fidx
for i in range(shape[0]):
for j in range(shape[1]):
cidx = i * shape[1] + j
fidx = i + j * shape[0]
if mode == 'fortran':
data[fidx] = cidx
data[cidx] = cidx
if use_callback:
result.callback_free_data = callback
return result
Jump to Line
Something went wrong with that request. Please try again.