[Distutils] Re: limiting symbols in C module

M.-A. Lemburg mal at egenix.com
Fri Sep 10 13:47:50 CEST 2004


Brandon Craig Rhodes wrote:
> "M.-A. Lemburg" <mal at egenix.com> writes:
> 
> 
>>There are probably a few cases where [a Python extension module
>>defining hundreds of extra symbols] may cause problems, but in
>>general, I don't see why distutils should try to strip symbols from
>>C extensions.  Is there a specific problem you are trying to solve?
> 
> 
> My "problem" is simply that my Python extension defines several
> hundred symbols (some of which are not at all specific to its task,
> like "range" and "start"), which violates section 1.12 of the
> _Extending and Embedding_ document:
> 
>    ... all symbols in extension modules should be declared static,
>    except for the module's initialization function, in order to avoid
>    name clashes with other extension modules.
> 
>    http://docs.python.org/ext/using-cobjects.html
> 
> This made me concerned that, unless I took measures to remove the
> extraneous symbols, I would be inviting lots of user complaints later
> when "range" and "start" and so forth wound up conflicting with
> symbols from other parts of Python on certain platforms.

In all the years I've been using Python with many different
extensions this issue has never come up.

> I will happily ignore the issue if the Extending and Embedding
> document is being overzealous; but if extraneous symbols are really
> not much of a problem, I'm surprised that so many extension modules
> are written as single huge .c files.

I think they only become a problem if one extension tries to
link to another extension dynamically and the linker find the
same symbol defined in multiple extensions. This doesn't work too
well in practice anyway, which is why the usual way to have
"linking" between extensions is to pass around a Python C object
holding the references to the API functions.

Could be wrong, though, or just lucky that the extensions pay
good attention to the quote from the docs you gave above.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Sep 10 2004)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::


More information about the Distutils-SIG mailing list