Skip to content

Instantly share code, notes, and snippets.

@andreasvc
Last active February 11, 2018 06:02
Show Gist options
  • Save andreasvc/8640956 to your computer and use it in GitHub Desktop.
Save andreasvc/8640956 to your computer and use it in GitHub Desktop.
Review of Learning Cython Programming, by Philip Herron

Learning Cython Programming

by Philip Herron

Birmingham: Packt Publishing, 2013, available in print and as ebook; this review is based on the PDF, 110 pp.

Reviewed by
Andreas van Cranenburgh
University of Amsterdam

This book provides some examples of using Cython to speed up Python programs, and extend existing software written in C. Cython is a superset of the Python language with optional static typing that gets translated to C code; the result is compiled and available from within Python as an extension module. It makes the process of gluing together efficient C code and convenient Python scripting easier. The book does not provide a systematic treatment of the Cython language, nor does it provide the background a Python programmer who hasn't programmed in C before would need to get up to speed with Cython.

I found the book somewhat haphazardly organized. The chapters seem to go from beginner to advanced to more advanced, with some generic section and chapter titles such as "more inspiration" and "further reading". For example, NumPy is only introduced in the last chapter, "further reading", and in the "Python 3" section at that. Another example is the section "Parsing large amounts of data", which is something that Cython is well suited for; unfortunately the section only discusses a script that uses ElementTree and replaces it with lxml (and the benchmark glosses over the fact that the standard library offers cElementTree).

I think a topical organization would have made more sense, e.g., numerical code, datastructures, concurrency, etc. This would also have made the book more balanced. However, the book is practical and hands on, so reading the book and following the examples will give the reader a good flavor of what's possible with Cython. The value it has over the Cython documentation is that it provides a number of worked out examples, for example extending the Tmux terminal manager. The code for the examples is available on GitHub.

References

http://www.packtpub.com/learning-cython-programming/book
https://github.com/redbrain/cython-book
http://www.cython.org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment