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

Try loading utemplate.compiled before utemplate.source (way less memory usage) #24

Open
orzechow opened this issue Dec 31, 2017 · 0 comments

Comments

@orzechow
Copy link
Contributor

orzechow commented Dec 31, 2017

When working with render_templates(), the whole utemplate library is loaded:

import utemplate.source

This was a too high memory demand in my use case on an ESP8266. So I ended up comiling the template on my dev machine, putting this on the device and loading the compiled version manually (which works great):

import utemplate.compiled
template_loader = utemplate.compiled.Loader(None, "templates")
template = template_loader.load("config.html")

for s in template(config):
    yield from response.awrite(s)

But it would be nice to use the same API with source or compiled templates.
So please try loading the compiled files in _load_template() first, before importing utemplate.source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant