In [ ]:
%load_ext cythonmagic
In [ ]:
%%cython
def testcython(int n):
return 3.1415**n
In [ ]:
print testcython(10)
In [ ]:
%%cython
from libc.string cimport strlen
def get_len(char *msg):
return strlen(msg)
In [ ]:
get_len("asdfasfd\0asdfasfd")
In [ ]:
%%cython
import numpy as np
def testmemview(double[:,::1] mv):
''' Tests roundtrip: python object -> cython typed memoryview -> python object '''
print np.sum(mv)
In [ ]:
from numpy import ones
testmemview(ones((10, 10)))
In [ ]: