[pypy-dev] Bringing Cython and PyPy closer together

Stefan Behnel stefan_ml at behnel.de
Sat Feb 18 10:27:51 CET 2012

Amaury Forgeot d'Arc, 18.02.2012 10:08:
> 2012/2/18 Stefan Behnel
>> Stefan Behnel, 15.02.2012 12:32:
>>> http://wiki.cython.org/enhancements/pypy
>> So, any volunteers or otherwise interested parties to help in getting this
>> to work? Anyone in for financial support?
> Actually I spent several evenings on this.
> I made some modifications to pypy, cython and lxml,
> and now I can compile and install cython, lxml, and they seem to work!
> For example::
>     html = etree.Element("html")
>     body = etree.SubElement(html, "body")
>     body.text = "TEXT"
>     br = etree.SubElement(body, "br")
>     br.tail = "TAIL"
>     html.xpath("//text()")
> Here are the changes I made, some parts are really hacks and should be
> polished:
> lxml: http://paste.pocoo.org/show/552903/
> cython: http://paste.pocoo.org/show/552904/
> pypy changes are already submitted.

Cool. Most of the changes look reasonable at first glance. I'll see what I
can apply on my side. We may get at least some of this into Cython 0.16
(which is close to release).

> As expected, the example above is much slower on pypy, about 15x slower
> than with cpython2.6.

Given that XML processing is currently slower in PyPy than in CPython, I
don't think that's all that bad. Users can still switch their imports to
ElementTree if they only want to push XML out and I imagine that lxml would
still be at least as fast as ElementTree under PyPy for the way in.

> And I still get crashes when running the lxml test suite.

I can imagine. ;)

> But the situation looks much better than before, support of all lxml
> features seems possible.

I think that's what matters to most users who want to do XML processing in


More information about the pypy-dev mailing list