@@ -783,7 +783,8 @@ At each step, we'll time and look at the output from::
783783AGC Example
784784-----------
785785
786- Another useful example is in:
786+ Another useful example of doing something useful, and using a numpy
787+ array is in:
787788
788789Examples/week-08-extensions/AGC_example
789790
@@ -793,7 +794,8 @@ It turns out that you can use some advanced numpy tricks to get pretty
793794good performancew with this filter, but you can't get full-on speed
794795without some compiled code.
795796
796- This example uses:
797+
798+ This example uses all of:
797799 * Pure Cython
798800 * C called from Cython
799801 * f2py and Fortran
@@ -879,6 +881,8 @@ created by SWIG
879881Creating a wrapper:
880882-------------------
881883
884+ (``Examples/week-08-extensions/swig ``)
885+
882886Create ``add.i ``::
883887
884888 %module add
@@ -900,11 +904,23 @@ Create ``setup.py``::
900904
901905.. nextslide ::
902906
903- And built it::
907+ And build it::
904908
905909 python setup.py build_ext --inplace
906910
907- then run the code::
911+ NOTE: distutils (and thus setuptools) "knows" about SWIG, so it does the
912+ swig step for you when you give it a \* .i file.
913+
914+ Notice what gets created:
915+
916+ * an ``add_wrap.c `` file -- the wrapper code.
917+ * an ``add.py `` file -- python code that calls the C function
918+ * an ``_add.so `` (or ``_add.pyd ``) file -- the compiled extension
919+
920+ .. nextslide ::
921+
922+
923+ You can then run the code::
908924
909925 python -c 'import add; print add.add(4,5)'
910926
@@ -913,7 +929,7 @@ http://www.swig.org/Doc2.0/SWIGDocumentation.html#Introduction_nn5
913929Installing SWIG
914930----------------
915931
916- On the SWIG download page, there is a source tarball for *nix, and
932+ On the SWIG download page, there is a source tarball for \ * nix, and
917933Windows binaries:
918934
919935http://www.swig.org/download.html
0 commit comments