[Bf-python] Pyrex - an easier way to write Python/C modules?

Stephen Swaney sswaney at centurytel.net
Fri Jan 7 17:55:27 CET 2005


On Fri, Jan 07, 2005 at 05:18:15PM +0100, Yann Vernier wrote:
> 
> Attributes aren't that hard to write in C (compared to any other cPython
> function), but the getattr/setattr code currently used is inefficient. I
> posted an example of how this should be done earlier. That said, Pyrex
> still makes it easier.

You can certainly criticize the code as being inefficient, but when a
lot of it was written, there was no other way.  In older versions of
Python, there was a great difference between built-in and user-defined
types.

You might as well bash James Watt for using that silly reciprocating
piston steam engine instead of a more modern multi-stage turbine
design.

As Python itself evolves and the difference between types and classes
disappears, we should definitely take advantage of the newer features
like the new attribute access methods.  Whether it is worthwhile to go
back and redo existing, working code is left as an exercise for the
reader.

My personal preference is for the more 'pythonic' attribute access
rather than the getStuff()/setStuff() style.  I would like to see
new code done this way.

> I went ahead and wrote a snippet that loads the Pyrex Compiler straight
> into SCons. While not complete - it doesn't collect dependencies and
> such - this makes it less platform reliant, I think.

One of the biggest benefits of using SCons is that it deals with
dependencies correctly.  Not a thing to give up lightly.

-- 
Stephen Swaney			
sswaney at centurytel.net




More information about the Bf-python mailing list