Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2b7762ee9d

Fetching latest commit…

Cannot retrieve the latest commit at this time

..
Failed to load latest commit information.
lib
misc
README
pango.outlang
presentation.pin

README

A comparison of different strategies for interfacing with C code from python.

All examples are for calculating a sequence of prime numbers.

prime.py
 - python algorithm to return an array of primes

libprime.c
libprime.h
 - An OO C-library prime_new(), prime_free(), prime_print()
 - Function based interface for computing primes

libprime_main.c
 - C test program for libprime OO interface

modprime.c
modprimesetup.py
 - Hand coded python module (and setup.py) for calling the
   function interface create_primes() function

pyxprime.pyx
 - Cython re-implementation of prime.py

ctlibprime.py
 - ctypes wrapper for the OO libprime interface. Note the extra
   data copy incurred when returning a newly allocated C-array
   from a c-library

pyxlibprime.pyx
 - Cython wrapper for the OO libprime interface. Again, we need
   an extra data copy at the return

ctnplibprime.py 
 - ctypes + numpy interface to the calculate_primes() function. By using a
   preallocated numpy array (and the numpy ctypes glue) we save a copy when
   returning the data
 - ctypes + numpy interface to create_primes(). Returns new data directly from
   the ctypes C-array without a copy (2 strategies)

pyxnpprime.pyx
 - cython + numpy interface to the create_primes function. Creates the numpy
   array from memory allocated in C and returns it to python (saves a copy)
 - cython + numpy interface to the compute_primes function. Numpy preallocates
   the array and passes the pointer to the first element to the c-library


Something went wrong with that request. Please try again.