-
Notifications
You must be signed in to change notification settings - Fork 0
fredrikhl/py-ext-test
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
ext_test ========= This package is my learing experiment with C-bindings in Python. It contains a native C-library `cmath', that consists of a couple of simple functions: - fib # Calculate a given number from the fibonacci sequence (recursively) - sum # Sum all natural numbers lower than a given threshold (by looping through the numbers, and adding them up). - hyp # Calculate the hypotenuse using the pythagoras theorem. - sin # Calculate an approximation of the sine of an angle (in degrees). The package contains four python modules that all implement these functions: - refmath # A pure-python port of `cmath' (for comparison). - pymath # Native implementation that wraps `cmath'. - ctmath # CTypes wrapper for `cmath'. - cffimath # CFFI wrapper for `cmath'. Use/install ============ To use this module, simply run `setup.py install'. This will compile and link all the implementations in the package, and install it in the local environment. Alternately, use `setup.py build_ext --inplace' to build and place the shared libraries in the source tree. This is also done if you run the unit tests (by running `setup.py test') Requirements ------------- - gcc, compiler toolchain. - python-devel, python headers to compile `pymath'. - cffi, python FFI module used in `cffimath'. Files ====== - cmath.* # The actual C implementations of the functions - Makefile # Makefile to compile `cmath' as a shared object library - pymath.* # CPython-wrappers and native CPython interface - ctmath.py # Ctypes wrapper for the shared object library - cffimath.py # CFFI wrapper for the shared object library - refmath.py # Pure-python implementations of the functions - setup.py # Distutils script to compile and install the module as a native # CPython extension. - runtests.py # Run tests. Standalone script generated by py.test.
About
Getting familiar with C extensions in Python, FFI, etc.