peterbe/premailer — pull request #91 by jonbretman (2014-11-19 01:00:24+00:00)
Title: Remove exclude_pseudoclasses option and improve performance

We have been using premailer for a while for a new internal email system sending fairly large volumes of emails and have encountered some severe performance issues, sometimes inlining css would take almost a second, which meant it was impossible to send the volume of emails needed within the time frames needed. So we started digging into where the performance issues were coming from and it turned out to be in `merge_styles`. We are now using a forked version of premailer with this change and we are seeing big performance improvements.

Delving a little deeper it appears that the option `exclude_pseudoclasses` is not really needed as as far as I can see it is not possible to inline pseudo selectors such as `:hover` or `::first-letter`. For an example see [this JSFiddle](http://jsfiddle.net/shvL1dj5/). This makes it much easier to implement `merge_styles` without using `cssutils`, which requires threading locks.

I'm aware that this is a breaking change but I think given the performance improvements, and the fact that the current behaviour actually produces invalid CSS, it is worth it.

Some timing using `timeit`:

```sh
# current master
>>> timeit.timeit("premailer.premailer.transform('

')", setup='import premailer', number=10000)
45.349464893341064

# this branch
>>> timeit.timeit("premailer.premailer.transform('

')", setup='import premailer', number=10000)
29.674472093582153

```