diff --git a/README.md b/README.md index 5443cf2640f100bdb550e2a3b6d83d37b11c9eae..5a082242c1949459fd6e3235b1e9151e7bcde74d 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ code. It also happens that I was familiar with Cython. It took me a couple of hours to figure out how to get this to work properly, and with no real tutorial or simple advice to follow, I made -(a starter kit)[https://version.helsinki.fi/weir/cython-and-scipy] +[a starter kit](https://version.helsinki.fi/weir/cython-and-scipy) showing a minimal working example. Note that I don't fully know all the jargon names given to bits of @@ -41,10 +41,10 @@ The starter kit contains the following files: basics](https://cython.readthedocs.io/en/latest/src/userguide/language_basics.html) for an explanation of what `cdef` is). We want to turn this into C, compile it, and then later on use it to instantiate a - `[scipy.LowLevelCallable](https://docs.scipy.org/doc/scipy/reference/generated/scipy.LowLevelCallable.html)` + [`scipy.LowLevelCallable`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.LowLevelCallable.html) instance so `scipy.integrate` can use that rather than working with interpreted python (which is slow). - + - `test.pxd` is a Cython "header" file (I don't know what the correct name is, but the [Cython documentation](https://cython.readthedocs.io/en/latest/src/tutorial/pxd_files.html) @@ -58,13 +58,19 @@ The starter kit contains the following files: The corresponding python module then has the attribute `__pyx_capi__`, which is also needed for `LowLevelCallable.from_cython()` to work. To be honest, I couldn't - find useful documentationa bout this, but I think this means that - it has a 'parallel' C interface, as it were - [this](https://github.com/ashwinvis/cython_capi/tree/master/using_pxd) - subdirectory of a repo by Ashwin Vishnu was useful. + find useful documentation about this, but I think this means that + it has a 'parallel' C interface, as it were. + + [This](https://github.com/ashwinvis/cython_capi/tree/master/using_pxd) + subdirectory of a repo by Ashwin Vishnu was useful, as was [this + article](http://pdebuyl.be/blog/2017/cython-module.html) by Pierre + de Buyl. - `setup.py` is the usual distutils thing, but it knows it's - building a Cython module because of the call to `cythonize()`. + building a Cython module because of the call to `cythonize()` and + thus detects the `.pxd` file (there is otherwise no relationship + between them, no `cimport` or similar); I'm not entirely + sure, though. - `run.py` uses the `integrand()` function from `test.pyx` to do some numerical integrals. @@ -96,7 +102,7 @@ To try this out you will need: python 3, cython Should be 21.333...: 21.3333 Uses - `[scipy.integrate.quad()](https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.quad.html#scipy.integrate.quad)` + [`scipy.integrate.quad()`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.quad.html#scipy.integrate.quad) to evaluate three numerical integrals. Note that I've tried to make it clear how to pass numerical coefficients from the python to the C code, so things don't need to be hardcoded.