Refs #910 - After Django introduced template based widget rendering, the number of context values which need prettifying has increased drastically, which can (given enough template contexts to render) cause pages using the template panel to become essentially unresponsive due to the sheer amount of data.
Refs #910 - After Django introduced template based widget rendering, the number of context values which need prettifying has increased drastically, which can (given enough template contexts to render) cause pages using the template panel to become essentially unresponsive due to the sheer amount of data.

Instead, when first seeing a new context layer, keep a copy of it + the formatted version, and when subsequently seeing the exact same layer (by
relying on the implicit __eq__ calls it is expected the lists's __contains__ will do) re-use the existing formatted version.

This cuts the number of pformat calls at a minimum by half, and ultimately (far) more than that due to re-use of the same one where possible.

jazzband/django-debug-toolbar,django-debug-toolbar/django-debug-toolbar,spookylukey/django-debug-toolbar,tim-schilling/django-debug-toolbar,spookylukey/django-debug-toolbar,tim-schilling/django-debug-toolbar,jazzband/django-debug-toolbar,django-debug-toolbar/django-debug-toolbar,django-debug-toolbar/django-debug-toolbar,jazzband/django-debug-toolbar,tim-schilling/django-debug-toolbar,spookylukey/django-debug-toolbar