EuroSciPy logo

EuroSciPy 2013

Brussels, Belgium - August 21-24 2013

Performance of Python runtimes on a non-numeric scientific code.

Riccardo Murri


The moduli space M_{g,n} of smooth Riemann surfaces is a topological space, which has been subject of much research both in algebraic geometry and in string theory. It is known since the '90s that this space has a triangulation indexed by a special kind of graphs,123 nicknamed "fat graphs".

Since graphs are combinatorial and discrete objects, a computational approach to the problem of computing topological invariants of M_{g,n} is now feasible; algorithms to enumerate fatgraphs and compute their graph homology have been devised in 4 and implemented in Python.

The Python library FatGHol used in 4 to reckon the rational homology of the moduli space of Riemann surfaces is an example of a non-numeric scientific code: most of the processing it does is generating graphs (represented by complex Python objects) and computing their isomorphisms (a triple of Python lists; again a nested data structure). These operations are repeated many times over: for example, the spaces M_{0,6} and M_{1,4} are triangulated by 4'583'322 and 747'664 "fatgraphs", respectively; but the number of such objects handled by the program is much larger, as many duplicates are generated and discarded in the process. A computational run for one of these spaces takes about one week of CPU time and hundreds of gigabytes of RAM.

This is an opportunity for every Python runtime to prove its strength in optimization. This poster compares the results and experiences gotten by running FatGHol with different Python runtimes (CPython, PyPy, Cython, etc.).


  1. Perturbative series and the moduli space of Riemann surfaces, R. C. Penner - J. Differential Geom, 1988 

  2. Formal (non)-commutative symplectic geometry, M. Kontsevich - The Gelfand Mathematical Seminars, 1990–1992 - Springer 

  3. On a theorem of Kontsevich, J. Conant, K. Vogtmann - Algebr. Geom. Topol, 2003 

  4. Fatgraph Algorithms and the Homology of the Kontsevich Complex, R. Murri - arXiv preprint arXiv:1202.1820, 2012