pygame and python 2.5

Ben Sizer kylotan at gmail.com
Sat Feb 10 17:36:14 EST 2007


On Feb 10, 8:42 am, Steve Holden <s... at holdenweb.com> wrote:
> Hendrik van Rooyen wrote:
> > <s... at pobox.com> wrote:
> > "Ben Sizer" <kylo... at gmail.com> wrote:
>
> >>     Ben> Python extensions written in C require recompilation for each new
> >>     Ben> version of Python, due to Python limitations.
>
> >> Can you propose a means to eliminate this limitation?
>
> > Yes.   - Instead of calling something, send it a message...
>
> I suppose you are proposing to use the ISO 19999.333 generic
> message-passing interface for this? The one that doesn't actually call a
> function to pass a message?

I'm assuming you're being facetious here..?

Of course, functions get called at the ends of the message passing
process, but those functions can stay the same across versions while
the messages themselves change. The important part is reducing the
binary interface between the two sides to a level where it's trivial
to guarantee that part of the equation is safe.

eg.
Instead of having PySomeType_FromLong(long value) exposed to the API,
you could have a PyAnyObject_FromLong(long value, char*
object_type_name). That function can return NULL and set up an
exception if it doesn't understand the object you asked for, so Python
versions earlier than the one that implement the type you want will
just raise an exception gracefully rather than not linking.

The other issue comes with interfaces that are fragile by definition -
eg. instead of returning a FILE* from Python to the extension,  return
the file descriptor and create the FILE* on the extension side with
fdopen.

--
Ben Sizer




More information about the Python-list mailing list