comparison piecrust/rendering.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 21e26ed867b6
children 96d363e2da4b
comparison
equal deleted inserted replaced
439:c0700c6d9545 440:32c7c2d219d2
280 data_ctx = DataBuildingContext(ctx.page, page_num=ctx.page_num) 280 data_ctx = DataBuildingContext(ctx.page, page_num=ctx.page_num)
281 data_ctx.pagination_source = ctx.pagination_source 281 data_ctx.pagination_source = ctx.pagination_source
282 data_ctx.pagination_filter = ctx.pagination_filter 282 data_ctx.pagination_filter = ctx.pagination_filter
283 page_data = build_page_data(data_ctx) 283 page_data = build_page_data(data_ctx)
284 if ctx.custom_data: 284 if ctx.custom_data:
285 page_data.update(ctx.custom_data) 285 page_data._appendMapping(ctx.custom_data)
286 return page_data 286 return page_data
287 287
288 288
289 def _do_render_page_segments_from_ctx(ctx): 289 def _do_render_page_segments_from_ctx(ctx):
290 page_data = _build_render_data(ctx) 290 page_data = _build_render_data(ctx)