[r-t] Writing method display software
lists at simpleigh.com
Thu Dec 3 21:50:25 UTC 2015
> I can't remember whether it has been mentioned in the context of this
> conversation, but there is a set of Python bindings for the Ringing Class
> Library at https://github.com/ringing-lib/ringing-lib-python.
It's probably worth saying a little more about this. The Ringing Class
Library is pretty fantastic, but arguably suffers from the disadvantage of
being written in C++. The development of the web has brought an explosion of
perfectly appropriate choice for a library implementation but isn't
particularly accessible to novice programmers, and I'd been thinking for a
while that it'd be worth writing a wrapper for the library in something more
high-level. I've toyed with PHP extension writing before - enough to know
this would be a fairly painful process, but luckily a change at work into
Python coincided with my discovery of Cython .
Cython transpiles Python syntax into a C or C++ source that can be compiled
into a Python extension. Simply using it makes code run faster, but it's
then possible to get more speed by adding type annotations in order to start
using native C or C++ types (e.g. C strings or raw integers) rather than
Python ones. More importantly it also provides good support for calling
Wrapping an external C++ class becomes a pretty simple process :
1. Find the header file of the class you want to wrap
2. Translate the header file into a Cython pxd file:
This isn't too hard - the code looks a lot like the original header file
3. Implement a class in pseudo-Python to call into a contained C++ class:
My Python "Row" class contains a C++ "row" class (cdef row *thisptr), and
each method calls through to the underlying implementation.
4. Spend more time writing unit tests and documentation than went into the
So far I've implemented the following classes from the Ringing Class
Library: Bell, Row, Group, Change, RowBlock and Method, so there's still
some way to go. Nevertheless this is enough to string together simple touch
searches. Hopefully there's potential here to blend the clarity of Python
with the speed of the underlying C++ implementation.
If you have a working implementation of the Ringing Class Library (i.e. your
*nix system can find the headers and libraries), a working gcc and Python
headers then it should be possible to install the Python wrappers from PyPI
using pip .
Source code is on GitHub at
https://github.com/ringing-lib/ringing-lib-python - pull requests very
Documentation is at http://ringing-lib-python.readthedocs.org/
The Ringing Class Library itself is now on GitHub too at
... and its website has moved to http://ringing-lib.github.io/ (although
there's still stuff on SourceForge).
 See http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html for
More information about the ringing-theory