Code Monkey home page Code Monkey logo

Comments (4)

guyskk avatar guyskk commented on May 26, 2024

Hi @Stranger6667, thank you for the proposal!

About Performance:

pynliner is really slow and I have ever encountered performance issue when render templates/email/feed_analysis.html.mako. The template contains a very large table, and need inline css for each cell. So the render process is very slow, and the final html is very large, which also cause email app rendering very slow.

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 might require changing the order of rendering for mako templates (pynliner doesn't transform Mako's syntax as css-inline does)

It's not suitable for my cases to change rendering order, as described above.

About ARM wheel

ARM64 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.

from rssant.

Stranger6667 avatar Stranger6667 commented on May 26, 2024

@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 pynliner takes ~2.3s vs ~8.2ms with css-inline. Though, with pre-inlining, it becomes much or less irrelevant, as switching to post-inlining will give a net-negative effect on performance in any case :) Probably it is something for me to consider - maybe css-inline may support templated input one day :)

Details on data generation
from 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 css-inline at the moment means a performance hit due to unconditional post-inlining (though, maybe template itself can be re-arranged to support css-inline, but it is too much for this change). premailer also malformed the template :( Let me know if there is anything I can do on my side here, and thank you for consideration :)

from rssant.

guyskk avatar guyskk commented on May 26, 2024

@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:

from rssant.

Stranger6667 avatar Stranger6667 commented on May 26, 2024

Thanks, @guyskk ! :)

from rssant.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.