8000 bpo-34002: Minor efficiency and clarity improvements in email package. by selik · Pull Request #7999 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-34002: Minor efficiency and clarity improvements in email package. #7999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 20, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Check intersection of two sets explicitly
Comparing ``len(a) > ``len(a - b)`` is essentially looking for an
intersection between the two sets. If set ``b`` does not intersect ``a``
then ``len(a - b)`` will be equal to ``len(a)``. This logic is more
clearly expressed as ``a & b``.
  • Loading branch information
selik committed Jun 28, 2018
commit d8bc2c08314414ee69c02967483ca4678484d915
6 changes: 2 additions & 4 deletions Lib/email/headerregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,8 @@ def __str__(self):
if self.display_name is None and len(self.addresses)==1:
return str(self.addresses[0])
disp = self.display_name
if disp is not None:
nameset = set(disp)
if len(nameset) > len(nameset-parser.SPECIALS):
disp = parser.quote_string(disp)
if disp is not None and set(disp) & parser.SPECIALS:
disp = parser.quote_string(disp)
adrstr = ", ".join(str(x) for x in self.addresses)
adrstr = ' ' + adrstr if adrstr else adrstr
return "{}:{};".format(disp, adrstr)
Expand Down
0