-
Notifications
You must be signed in to change notification settings - Fork 138
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
Considering an alternative to pynliner #114
Comments
Hi @Stranger6667, thank you for the proposal! About Performance:
My solution is pre inline css on mako template and cache the template, then do mako rendering. So only need inline css once, and reuse the inlined template. FYI: email_template.py And to avoid too large html, I have to use css classes instead of inline styles.
It's not suitable for my cases to change rendering order, as described above. About ARM wheelARM64 is required for rssant. Not sure whether it's hard to install from source or not. It's possible to build ARM64 wheel from source via docker multi-stage build. |
@guyskk Thank you for providing the context! Re ARM64 wheel: I added wheels for Python 3.8+ on macOS ARM64 and some more platforms including manylinux aarch64, musllinux aarch64 etc. Hopefully, it satisfies the requirements :) Let me know if it is not sufficient, and rssant needs e.g. Python 3.7 on ARM64 Re performance: Pre-inlining is a neat trick indeed! :) I tried to render that template with some randomly generated data (see below) and post-inlining with Details on data generationfrom hypothesis import provisional as pr, strategies as st, settings, given
... # import `Feed` from feed_analysis here - locally I copied the relevant definitions
feeds = st.builds(
Feed,
id=st.integers(min_value=1),
domain=pr.domains(),
status=st.sampled_from(["pending", "updating", "ready", "error", "discard"]),
use_proxy=st.booleans(),
response_status=st.integers(min_value=200, max_value=500),
freeze_level=st.integers(min_value=1, max_value=10)
)
out = []
@given(feeds)
@settings(max_examples=10000)
def generate(x):
out.append(x)
# calling generate() will add 10000 random `Feed` instances to `out`
# Then generating snapshots from it via `compute_snapshot`, and passing them to `compute_report` So, effectively it looks like the only way to use |
@Stranger6667 Seems nothing needs to be done for inlining css in rssant project. If you have interest in high performance project, maybe take a look at this optics science project: |
Thanks, @guyskk ! :) |
Hello!
I noticed that
rssant
uses pynliner where the last commit was in Jan 2017, sopynliner
, unfortunately, looks abandoned. Therefore I'd like to propose replacing it with css-inline (that I authored) or some other maintained alternative (e.g. premailer).css-inline
is significantly faster - a sample HTML fromtemplates/email/reset_password.html
is processed locally in ~140µs vs. ~28ms withpynliner
vs. ~2ms withpremailer
. Though, it adds a dependency on the Rust toolchain for some users (where wheels aren't provided, like arm64) and generally supports fewer architectures thanlxml
-based libraries (pynliner
&premailer
). However, I don't know whether it is a concern. The replacement itself would look like this:+ it might require changing the order of rendering for mako templates (
pynliner
doesn't transform Mako's syntax ascss-inline
does)Let me know what do you think :) If you'll be ok with replacing
pynliner
, I'd be happy to submit a PRThe text was updated successfully, but these errors were encountered: