[Pyrex] Pythonic wrapping of libxml2
Martijn Faassen
faassen at infrae.com
Tue Sep 28 14:52:03 CEST 2004
vng1 at mac.com wrote:
> Yep. Wrapping libxml2. :)
You do realize that libxml2 has already a Python-wrapper included, right?
I want to improve on it as it's very low-level and not very Pythonic. If
you have the same goal, we may want to join efforts. We could both wrap
different parts of the API; I've been focusing on the tree API for now,
and you seem to be interested in XPath. There's an lxml repository, and
a lxml mailing list, which you may like to join. I will also try to hang
out at #lxml at freenode on irc.
Here's the svn repository:
http://codespeak.net/svn/lxml/
and here's the mailing lists:
http://codespeak.net/mailman/listinfo/lxml-dev
http://codespeak.net/mailman/listinfo/lxml-checkins
My goal is to provide Pythonic APIs, in particular handling things like
memory management and Python-unicode. Proper Python exceptions should
also be raised in case of errors. I'm not basing my work off the
auto-generated system that's included with libxml2, useful as it is, as
I want to raise the level of the API significantly and working more
directly with the C through Pyrex is about as easy as basing the new
system on top of the autogenerated code, and more flexible.
> Ok - so my C is worse than rusty - I can barely read C anymore.
>
> I've got the following signature that I'd like to wrap up - it's a
> function pointer.
>
> 174 typedef xmlXPathObjectPtr (*xmlXPathAxisFunc)
> (xmlXPathParserContextPtr ctxt,
> 175 xmlXPathObjectPtr cur);
>
> So - how does one wrap such a beastie in Pyrex - or is it even
> possible? The only reference I see to fp's and Pyrex are here:
>
> http://lists.copyleft.no/pipermail/pyrex/2004-March/thread.html#623
>
> but I'm left pretty confused - most likely because i can't remember what
> to actually _use_ function pointers for anymore.
I'd need to figure it out too. Come and join me if you like. :)
In python it's so simple that the C level way to do it looks
spectacularly strange. Basically it allows you to parameterize code with
logic, not just data. In OO languages you'd often use polymorphism for
this effect.
Regards,
Martijn
More information about the Pyrex
mailing list