From b929ca10dd85854d305c1f4f354ff8934379ff38 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 12 May 2019 06:50:31 -0700 Subject: [PATCH] Drop unnecessary call to .keys() Iterating a dict is the same as iterating the dict keys. Inspired by Lennart Regebro PyCon 2017 talk "Prehistoric Patterns in Python". https://www.youtube.com/watch?v=V5-JH23Vk0I --- requests_toolbelt/utils/dump.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requests_toolbelt/utils/dump.py b/requests_toolbelt/utils/dump.py index 23b35e7..fcec64e 100644 --- a/requests_toolbelt/utils/dump.py +++ b/requests_toolbelt/utils/dump.py @@ -98,7 +98,7 @@ def _dump_response_data(response, prefixes, bytearr): _coerce_to_bytes(response.reason) + b'\r\n') headers = raw.headers - for name in headers.keys(): + for name in headers: for value in headers.getlist(name): bytearr.extend(prefix + _format_header(name, value))