pyvm -- faster python

Roger Binns rogerb at rogerbinns.com
Wed May 11 12:47:49 EDT 2005


 "Stelios Xanthakis" <sxanth at ceid.upatras.gr> wrote in message news:mailman.333.1115805199.29826.python-list at python.org...
>> - hacking SWIG.  Shouldn't be too hard and will instantly give
>> us access to wx, qt, etc.

 Have you ever written a non-trivial extension using Swig?  It isn't
as simple as you would think.  There are a lot of little things to
deal with, usually because because of the mismatch between C/C++
semantics and convention and Python library expectations.  You have
to do a fair amount of work to fix all that using C code, Python
code and sometimes parts of the internals of Swig-Python. wxPython
has used a modified version of Swig for most of its lifetime.

Some people also have issues with Swig staying compatible with itself:

  http://bob.pythonmac.org/archives/2005/03/11/swig-hate/

PyQT uses another tool to do the wrapping - SIP.

Tools like Swig have been in the business of exposing C/C++ to Python
for years and are still suboptimal.  I believe you will find "hacking
SWIG" and actually porting an existing project that uses it to be
hard.

I would suggest looking in the lib/python directory of Swig to get an
idea of what you have to start with.  Note how there is minimal overlap
with the Java directory to pick one example.

>> The thing is that the C API of pyvm is IMHO superior and much more fun.

That is not under dispute.  The suggestion is that you *also* provide a
way of running existing extensions, even if it is slow and inferior,
ideally without even having to recompile them.  (If you do require a
recompile then you'll also have to port/invent an equivalent to distutils).

>> You can wrap the entire sockets module in a couple of hours and also
>> enjoy it.

sockets are easy.  There are no structures, plain integer handles, no pointers,
about 8 methods and a few constants.  About the only thing to remember is
to deal with threading correctly.

>> I wish I could clone myself to port the entire std library
>> to pyvm -- so much fun it is:)

Well, if you don't provide an easy way to move existing stuff across, you'll
end up doing just that yourself!

Roger 





More information about the Python-list mailing list