File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,15 +147,17 @@ def add_entry(
147147 dumps = _encode
148148 if isinstance (startedDateTime , datetime ):
149149 startedDateTime = startedDateTime .isoformat ()
150- cache = cache or Cache ()
150+ # The common case is no cache info; avoid allocating a Cache and
151+ # encoding an empty dict (``dumps(Cache().asdict())`` is just ``"{}"``).
152+ cache_json = "{}" if cache is None else dumps (cache .asdict ())
151153 chunk = (
152154 f"{ separator } {{"
153155 f'\n "startedDateTime": "{ startedDateTime } ",'
154156 f'\n "time": { time } ,'
155157 f'\n "request": { dumps (request .asdict ())} ,'
156158 f'\n "response": { dumps (response .asdict ())} ,'
157159 f'\n "timings": { dumps (timings .asdict ())} ,'
158- f'\n "cache": { dumps ( cache . asdict ()) } '
160+ f'\n "cache": { cache_json } '
159161 )
160162 if serverIPAddress :
161163 chunk += f',\n "serverIPAddress": { dumps (serverIPAddress )} '
You can’t perform that action at this time.
0 commit comments