summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-01-07 21:26:05 (GMT)
committerGitHub <noreply@github.com>2023-01-07 21:26:05 (GMT)
commit6746135b0722a5359ce6346554c847afba603b5a (patch)
tree6e4951fd9124558afddd5f97f418121bd86f4743 /Lib/email
parent47b9f83a83db288c652e43567c7b0f74d87a29be (diff)
downloadcpython-6746135b0722a5359ce6346554c847afba603b5a.zip
cpython-6746135b0722a5359ce6346554c847afba603b5a.tar.gz
cpython-6746135b0722a5359ce6346554c847afba603b5a.tar.bz2
gh-100792: Make `email.message.Message.__contains__` twice as fast (#100793)
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/message.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/email/message.py b/Lib/email/message.py
index 65fda50..b540c33 100644
--- a/Lib/email/message.py
+++ b/Lib/email/message.py
@@ -448,7 +448,11 @@ class Message:
self._headers = newheaders
def __contains__(self, name):
- return name.lower() in [k.lower() for k, v in self._headers]
+ name_lower = name.lower()
+ for k, v in self._headers:
+ if name_lower == k.lower():
+ return True
+ return False
def __iter__(self):
for field, value in self._headers: