scipy.weave'd dpmod.  100x speedup