Templating redux#13
Draft
Tronic wants to merge 2 commits into
Draft
Conversation
- Remove mutable template-tag leftovers: - Builder.render(), _render_piece(), _render_value() - Builder.__setattr__() slot setter - trailing-underscore handling for placeholders - debug _optimize() method - Update tests to use immutable Template objects only - Update README and Template docstrings for new API - Fix benchmark unused imports and formatting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A new templating implementation replacing the old one introduced in version 1.3. The templates are immutable objects instantiated at render time with dynamic content but not internally preserving such content anymore. We are running far faster than the old template system, and can now properly support
forloops for nested items (sub templates) which the old one did not.The templating is for the highest possible performance and also to ease the construction of complex documents.
This is intended for 2.0 release, as it breaks compatibility with 1.3 templates.
New Syntax
Performance
The benchmark script shows difference between no templating (built from scratch) and the new system. The old system was slower than building from scratch and not really comparable here. Python web frameworks take some 0.5ms to even Hello World. The build from scratch for a large document can reduce the maximal req/s, while if templated it hardly affects performance.