I've updated the patch.
I also removed the mutability checks from some of the backends. The central user-facing point to implement them is in GenericGraph
/ GenericGraph_pyx
. This is similar to the matrix code where we, for example, don't patch linbox to support (im)mutability.
It seems there is quite a bit of overhead in graph construction since the GenericGraph._backend
is a Python class. This means various dictionary lookups to locate add_vertex
and friends. You could shave off a lot of overhead by
- Move the construction methods (
add_vertex
etc) from GenericGraph
to GenericGraph_pyx
- Switch
GenericGraphBackend
and its subclasses to Cython and make its methods cdef
- Equip
GenericGraph_pyx
with a Cython attribute cdef GenericGraphBackend _backend
See also http://docs.cython.org/src/userguide/early_binding_for_speed.html But thats material for another ticket.
Once all the constructions methods are in GenericGraph_pyx
it'll also be easy to switch the mutability check to a very fast inline function.