Skip to content

Commit e18b22d

Browse files
committed
final? version of the presentation.
1 parent e71b960 commit e18b22d

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

slides_sources/source/extensions.rst

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,8 @@ At each step, we'll time and look at the output from::
783783
AGC 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

788789
Examples/week-08-extensions/AGC_example
789790

@@ -793,7 +794,8 @@ It turns out that you can use some advanced numpy tricks to get pretty
793794
good performancew with this filter, but you can't get full-on speed
794795
without 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
879881
Creating a wrapper:
880882
-------------------
881883

884+
(``Examples/week-08-extensions/swig``)
885+
882886
Create ``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
913929
Installing 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
917933
Windows binaries:
918934

919935
http://www.swig.org/download.html

0 commit comments

Comments
 (0)