Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run on PyPy #64

Closed
SimonSapin opened this issue Mar 23, 2013 · 5 comments
Closed

Run on PyPy #64

SimonSapin opened this issue Mar 23, 2013 · 5 comments
Labels
feature New feature that should be supported performance Too slow renderings

Comments

@SimonSapin
Copy link
Member

Switching to CFFI removed a big obstacle to running WeasyPrint on PyPy. The test suite now actually passes, but bigger document (anything useful) fail because of https://github.com/lxml/lxml/issues/99.

I’m hopeful that PyPy can bring great speed improvements, although there is absolutely no data yet.

@dsas
Copy link

dsas commented Apr 7, 2014

It looks like lxml have moved their bug tracker to launchpad, can you remember what the lxml issue was @SimonSapin ?

@SimonSapin
Copy link
Member Author

@SimonSapin
Copy link
Member Author

PyPy developers said on IRC that this bug was on the lxml side. lxml’s developer said he doesn’t care much about PyPy compatibility, because PyPy don’t seem to care much about maintaining cpyext (PyPy’s compatibility layer for C extensions, including anything using Cython like lxml.) PyPy developers say cpyext sucks, and the Right Thing to do is to use CFFI. Someone started porting lxml to CFFI but that doesn’t look very active. (Last commit 10 months ago.)

My current plan is to move WeasyPrint away from lxml by using cssselect2 instead of cssselect and thus not rely on lxml’s XPath implementation for Selectors. However, there are still design decisions to make for cssselect2 about what kind of tree it should work on. Ideally, I’d like projects other than WeasyPrint that use cssselect to move to cssselect2, since cssselect is broken in interesting ways because XPath sucks. However yet, I’m working on other things at the moment and not spending much time (if any) on all this.

@SimonSapin
Copy link
Member Author

I wrote up Kozea/cssselect2#1, in case anyone’s interested.

@liZe
Copy link
Member

liZe commented Jul 29, 2016

I've tested with pypy 5.3.1 and it works very well. lxml now has an "official" support of pypy and everything else is OK, so 🍻.

lxml doesn't work (yet) with pypy3 (I've tried 5.2.0-a0), but there should be no problem when an updated version of pypy3 is released.

Here's the incredibly-awesomly-reliable benchmark on the whole HTML5 spec (1340 pages PDF generated):

  • pypy 5.3.1 : 346 seconds,
  • python 3.4.5 : 369 sseconds.

Yay, ≃10% faster!

Bonus question: why does pypy generate a 30MB PDF when python's generated PDF is 15MB? I'm soooooo excited, I'd love to spend days and weeks finding why!

(Well, my browser can do this in 4.7 seconds including JS, but it doesn't know how to break a table between two pages 😉.)

@liZe liZe closed this as completed Jul 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature that should be supported performance Too slow renderings
Projects
None yet
Development

No branches or pull requests

3 participants