Skip to content

Instantly share code, notes, and snippets.

@yuyu2172
Created January 20, 2018 02:29
Show Gist options
  • Save yuyu2172/8f9347728d377bb33a6ec3d5d57f2829 to your computer and use it in GitHub Desktop.
Save yuyu2172/8f9347728d377bb33a6ec3d5d57f2829 to your computer and use it in GitHub Desktop.
cpdef pass_by_ref():
cdef int x
set_integer_ref(x)
return x
cpdef pass_by_ptr_0():
cdef int[1] x
set_integer_ptr(x)
return x[0]
cpdef pass_by_ptr_1():
cdef np.ndarray[int, ndim=1, mode='c'] x
x = np.zeros((1,), dtype=np.int32)
set_integer_ptr(&x[0])
return x[0]
cpdef pass_by_ref_ptr():
cdef int* x
set_integer_ref_ptr(x)
return x[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment