[Python-Dev] Python build question (fixing pymath.c).

Mark Dickinson dickinsm at gmail.com
Sun Sep 27 09:21:16 CEST 2009

Hello all,

I'm looking for advice on how to clean up an ugliness (one
that I'm at least partly responsible for) in the Python build setup.

Here's the problem:  some of the exported functions (e.g. atanh,
log1p) in the Python/pymath.c file aren't needed by the Python core
at all; they're exported solely for use in the math and cmath modules.
Even worse, these exported functions have no '_Py' or 'Py' prefix.

Since I'm currently working on adding some oft-requested
functions to the math module (gamma, lgamma, erf, ...) it seemed
like a good time to clean this up.

So I've now got a file Modules/math_support.c that contains
some functions needed by both mathmodule.c and
cmathmodule.c, as well as a couple of functions only
currently needed by the math module.  How should I incorporate
this file into the build?

One obvious solution seems to be to build an extra math_support.so
file that's then used by both mathmodule.so and cmathmodule.so.
Is this a sensible solution?  Are there better ways?

A complication to bear in mind is that some users may want to
alter Modules/Setup.dist so that either the math module and/or
the cmath module is included in the core Python executable.

Cluelessly yours,


More information about the Python-Dev mailing list