!ls /usr/lib/ from ctypes import CDLL libc_name = 'libc.dylib' # OSX # libc_name = 'libc.so.6' # Linux # libc_name = 'libc.dll' # Windows libc = CDLL(libc_name) libc.time print "Seconds since January 1, 1970:" print libc.time() %%file my_sum.c #include // sum all the values in the array x // x is a pointer to a memory block // of length n int sum(int *x, int n) { int i, counter; counter = 0; for(i=0; i // Define a simple array struct, containing // a pointer and a length struct Array{ int *x; int n; }; // Sum the values in the array struct int sum(struct Array a) { int counter, i; counter = 0; for(i=0; i= 4: return i return max_iter def create_fractal(Nx, Ny, xmin, xmax, ymin, ymax, max_iter): """Create and return a fractal image""" image = np.zeros((Ny, Nx), dtype=float) dx = (xmax - xmin) * 1. / Nx dy = (ymax - ymin) * 1. / Ny for x in range(Nx): rpart = xmin + x * dx for y in range(Ny): ipart = ymin + y * dy color = mandel(rpart, ipart, max_iter) image[y, x] = color return image image = create_fractal(300, 200, -2, 1, -1, 1, 20) plt.imshow(image, cmap=plt.cm.jet)