Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'static': 0.04; 'suppose': 0.07; 'variables': 0.07; 'closest': 0.09; 'api': 0.11; 'template': 0.14; '<body>': 0.16; 'advance!': 0.16; 'flush': 0.16; 'presume': 0.16; 'subject:possible': 0.16; 'tcp': 0.16; 'all,': 0.19; 'pfxlen:0': 0.19; 'possible,': 0.19; 'later': 0.20; 'byte': 0.24; 'skip:% 10': 0.24; 'typical': 0.24; 'looks': 0.24; "i've": 0.25; 'posts': 0.26; 'query': 0.26; 'second': 0.26; 'to:2**1': 0.27; 'function': 0.29; 'to:no real name:2**1': 0.29; 'start,': 0.30; 'streaming': 0.30; 'message-id:@mail.gmail.com': 0.30; 'websites.': 0.31; 'received:google.com': 0.35; 'there': 0.35; 'skip:j 20': 0.36; 'thanks': 0.36; 'possible': 0.36; 'subject:?': 0.36; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'skip:& 20': 0.39; 'to:addr:python.org': 0.39; 'skip:\xc2 10': 0.60; 'first': 0.61; 'making': 0.63; 'name': 0.63; 'happen': 0.63; 'great': 0.65; 'results': 0.69; 'partial': 0.84; 'crucial': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=g606LaZLe8fcjOs9KsqwVai9+O5tayeJCmD+Pojo6CA=; b=SrN+YmOeQ+qK70eoyCNYwRxE74uME7jsH2tsrh+19vP2cjvCbNTJeYE+2Uhwz8YZtB 9bbkPj2osqmx8U6/DMgcNAbzXgD94KzSEehTo3/Yb0fyoh5bLrqXiGJ0QoWz4DOp3VhM kVlNl3iFX5GyeJSLWGFvdxEdS4ijh6AdVFi8luZhkdxwp73EjcfnFmXNtaxn2jwQYZGO lsZtlKEE45GCLFzNs/ahpUAs3g5QJUuk2l7xAXwCMIJ/GAjfxR0Eb62PYblfWHX/jj7G kpdTmEd6VhZ8uaQK3RalgV4M80vZ2tSwslavMFGHWd1W6g//sSnft7QDYJMv/3SCsWBw t3VQ== X-Received: by 10.60.33.35 with SMTP id o3mr44172768oei.7.1405994448827; Mon, 21 Jul 2014 19:00:48 -0700 (PDT) MIME-Version: 1.0 From: est Date: Tue, 22 Jul 2014 10:00:28 +0800 Subject: async, on-demand lazy rendering for jinja2 possible? To: pocoo-libs@googlegroups.com, python-list@python.org Content-Type: multipart/alternative; boundary=089e011842a6adbce204febe97d2 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 86 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1405994458 news.xs4all.nl 2837 [2001:888:2000:d::a6]:49754 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74966 --089e011842a6adbce204febe97d2 Content-Type: text/plain; charset=UTF-8 Hi all, Been reading @igrigorik's posts https://www.igvita.com/archives/ I found that flush response as early as possible is crucial for a website performance. I wanna make Time To First Byte (TTTFB) happen as early as possible with a Jinja2 site, Suppose a typical Jinja2 template: {{ site_title }}
    {% for item in items %}
  • item
  • {% endfor %}
Let's presume site_title is static and known in view function from the start, I wanna flush everything before to the client as early as possible, then items was a query from db, it's kinda slower, let's flush the everything below later in a second TCP packet. This looks like impossible at the moment. I searched the Jinja2 docs, the closest thing I've found is the streaming template API jinja2.Template('Hello {{ name }}!').stream(name='foo') Which still requires all variables to be ready before rendering. Is there a way to stream partial template results with partial template variables? This would be great help making faster websites. Other template engine than Jinja2 is welcome as long as it's in python! Thanks in advance! --089e011842a6adbce204febe97d2 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi all,

Been reading @igrigorik's p= osts=C2=A0ht= tps://www.igvita.com/archives/=C2=A0

I found t= hat flush response as early as possible is crucial for a website performanc= e.

I wanna make Time To First Byte (TTTFB) happen as early= as possible with a Jinja2 site,=C2=A0

Suppose a t= ypical Jinja2 template:

<html><head>
=C2=A0 <title>{{ site_title }}</title>
</head= ><body>
<ul>
{% for item in items %}
=C2=A0 <li>item</li>
{% endfor %}
</ul= >
</body></html>

Let's presume site_= title is static and known in view function from the start, I wanna flush ev= erything before <body> to the client as early as possible, then items= was a query from db, it's kinda slower, let's flush the everything= below =C2=A0<body> later in a second TCP packet.

This looks like impossible at the moment. I searched th= e Jinja2 docs, the closest thing I've found is the streaming template A= PI

jinja2.Template('Hello {{ name }}!'= ).stream(name=3D'foo')

Which still requires all variables to be ready be= fore rendering.

Is there a way to stream partial t= emplate results with partial template variables? This would be great help m= aking faster websites. Other template engine than Jinja2 is welcome as long= as it's in python! Thanks in advance!
--089e011842a6adbce204febe97d2--