merits of Lisp vs Python

Graham Dumpleton Graham.Dumpleton at gmail.com
Sun Mar 11 03:45:25 CET 2007


On Mar 11, 12:31 pm, j... at pobox.com (John J. Lee) wrote:
> John Nagle <n... at animats.com> writes:
> > John J. Lee wrote:
> > > John Nagle <n... at animats.com> writes:
> > > [...]
>
> > >>    Python, on the other hand, is uphill all the way.  Constant trouble
> > >>with version issues, especially with C components called from Python.
> > >>MySQLdb, M2Crypto, SSL - they all have platform/version
> > >>incompatibility problems.  I just spent three days making M2Crypto
> > >>work on a new Linux server with a different Red Hat version.
> > >>Neither Python's packaging tools nor the platform's packaging
> > >>tools deal adequately with these issues.
> > > [...]
> > > You haven't been usingmod_python, by any chance?
> > > John
>
> >     No, haven't started to deal with that yet.  Still using
> > CGI.  Not sure whether to usemod_pythonor fastcgi for the
> > small requests where the Python load time swamps the time
> > to do one SQL select and reply.  Comments?
>
> mod_pythonrelies on an unsupported feature of Python, namedly
> multiple interpreters --> risk of more pain with C extensions.

As usual, those bashing up on mod_python tend not to really know what
they are talking about. :-(

Although multiple Python interpreters cannot be manipulated directly
from within a Python script, they can from the Python C API and it is
very much a feature of Python and has been for a long time.

The only issue with multiple sub interpreters in respect of C
extension modules is that implementers of those C extension modules
take the easy path and use the simplified thread API for GIL locking.
The consequence of them doing that is that their C extension module
may not work when used in anything but the first interpreter created
by Python. If instead of using the simplified thread API for GIL
locking they used other parts of the Python threading API as
appropriate and did thread lock handling properly for multiple
interpreters, there would not be an issue.

Even so, to get such a C extension module working in the context of
mod_python simply means telling mod_python to run that particular
application in the first interpreter instance by specifying the
mod_python directive:

  PythonInterpreter main_interpreter

Thus, the problem is not mod_python at all, but that the C extension
modules implementer didn't bother to implement their module so as to
be usable within a system such as mod_python where multiple
interpreters are used. Further, mod_python even provides a way to work
around the problems with such third party C extension modules.

If you feel that this is not the case and mod_python is still broken
in some way, please properly explain what the problem is.

PS. Yes I do know that forcing using of main interpreter in mod_python
only helps solve this problem in mod_python 3.2 and later and did not
help with older versions.

Graham




More information about the Python-list mailing list