Python C extension dealing with polynomials