comparison piecrust/data/debug.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 bd56d9acd6ef
children 93b656f0af54
comparison
equal deleted inserted replaced
439:c0700c6d9545 440:32c7c2d219d2
1 import re 1 import re
2 import io 2 import io
3 import html 3 import html
4 import logging 4 import logging
5 import collections 5 import collections
6 import collections.abc
6 from piecrust import APP_VERSION, PIECRUST_URL 7 from piecrust import APP_VERSION, PIECRUST_URL
7 from piecrust.page import FLAG_RAW_CACHE_VALID 8 from piecrust.page import FLAG_RAW_CACHE_VALID
8 9
9 10
10 logger = logging.getLogger(__name__) 11 logger = logging.getLogger(__name__)
160 def _renderValue(self, data, path): 161 def _renderValue(self, data, path):
161 if data is None: 162 if data is None:
162 self._write('&lt;null&gt;') 163 self._write('&lt;null&gt;')
163 return 164 return
164 165
165 if isinstance(data, dict): 166 if isinstance(data, (dict, collections.abc.Mapping)):
166 self._renderCollapsableValueStart(path) 167 self._renderCollapsableValueStart(path)
167 with IndentScope(self): 168 with IndentScope(self):
168 self._renderDict(data, path) 169 self._renderDict(data, path)
169 self._renderCollapsableValueEnd() 170 self._renderCollapsableValueEnd()
170 return 171 return