Mercurial > piecrust2
diff piecrust/templating/pystacheengine.py @ 440:32c7c2d219d2
performance: Refactor how data is managed to reduce copying.
* Make use of `collections.abc.Mapping` to better identify things that are
supposed to look like dictionaries.
* Instead of handling "overlay" of data in a dict tree in each different data
object, make all objects `Mapping`s and handle merging at a higher level
with the new `MergedMapping` object.
* Since this new object is read-only, remove the need for deep-copying of
app and page configurations.
* Split data classes into separate modules.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 28 Jun 2015 08:22:39 -0700 |
parents | ca5a3c970263 |
children | 96d363e2da4b |
line wrap: on
line diff
--- a/piecrust/templating/pystacheengine.py Sat Jun 27 22:28:32 2015 -0700 +++ b/piecrust/templating/pystacheengine.py Sun Jun 28 08:22:39 2015 -0700 @@ -1,4 +1,5 @@ import logging +import collections.abc import pystache import pystache.common from piecrust.templating.base import ( @@ -70,7 +71,9 @@ # a list. This is just plain wrong, but it will take a while before # the project can get patches on Pypi. res = mrc(stack, name) - if res is not None and res.__class__.__name__ in _knowns: + if res is not None and ( + res.__class__.__name__ in _knowns or + isinstance(res, collections.abc.Mapping)): res = [res] return res