-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
bpo-30296: Partially revert #1489. #2624
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
bpo-30296: Partially revert #1489. #2624
Conversation
@serhiy-storchaka, thanks for your PR! By analyzing the history of the files in this pull request, we identified @zestyping, @pitrou and @loewis to be potential reviewers. |
Lib/email/headerregistry.py
Outdated
@@ -369,8 +369,8 @@ def groups(self): | |||
@property | |||
def addresses(self): | |||
if self._addresses is None: | |||
self._addresses = tuple(address for group in self._groups | |||
for address in group.addresses) | |||
self._addresses = tuple([address for group in self._groups |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The list comprehension is not necessary and doesn't improve the code. This should stay as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The generator expression is slower. If you are fine with tiny performance regression introduced by the previous change I'll keep it.
Lib/inspect.py
Outdated
@@ -389,7 +389,7 @@ def classify_class_attrs(cls): | |||
|
|||
mro = getmro(cls) | |||
metamro = getmro(type(cls)) # for attributes stored in the metaclass | |||
metamro = tuple(cls for cls in metamro if cls not in (type, object)) | |||
metamro = tuple([cls for cls in metamro if cls not in (type, object)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The list comprehension is not necessary and doesn't improve the code. This should stay as-is.
@@ -463,7 +463,7 @@ def configure_custom(self, config): | |||
c = self.resolve(c) | |||
props = config.pop('.', None) | |||
# Check for valid identifiers | |||
kwargs = dict((k, config[k]) for k in config if valid_ident(k)) | |||
kwargs = {k: config[k] for k in config if valid_ident(k)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an improvement. Go ahead.
@@ -726,7 +726,7 @@ def configure_handler(self, config): | |||
config['address'] = self.as_tuple(config['address']) | |||
factory = klass | |||
props = config.pop('.', None) | |||
kwargs = dict((k, config[k]) for k in config if valid_ident(k)) | |||
kwargs = {k: config[k] for k in config if valid_ident(k)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an improvement. Go ahead.
Lib/pathlib.py
Outdated
@@ -114,7 +114,8 @@ class _WindowsFlavour(_Flavour): | |||
|
|||
is_supported = (os.name == 'nt') | |||
|
|||
drive_letters = set('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') | |||
drive_letters = set('abcdefghijklmnopqrstuvwxyz' | |||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is unnecessary and not an improvement. Please leave as-is.
Adding a multi-line statement with implicit string concatenation doesn't make the code simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is too long and don't conform PEP 8.
Lib/turtle.py
Outdated
@@ -1175,7 +1175,7 @@ def _color(self, cstr): | |||
cl = [16*int(cstr[h], 16) for h in cstr[1:]] | |||
else: | |||
raise TurtleGraphicsError("bad colorstring: %s" % cstr) | |||
return tuple(c * self._colormode/255 for c in cl) | |||
return tuple([c * self._colormode/255 for c in cl]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The list comprehension is not necessary and doesn't improve the code. This should stay as-is.
Lib/turtle.py
Outdated
@@ -2989,7 +2989,7 @@ def _getshapepoly(self, polygon, compound=False): | |||
t11, t12, t21, t22 = l, 0, 0, l | |||
elif self._resizemode == "noresize": | |||
return polygon | |||
return tuple((t11*x + t12*y, t21*x + t22*y) for (x, y) in polygon) | |||
return tuple([(t11*x + t12*y, t21*x + t22*y) for (x, y) in polygon]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The list comprehension is not necessary and doesn't improve the code. This should stay as-is.
@@ -3839,7 +3839,7 @@ def write_docstringdict(filename="turtle_docstringdict"): | |||
docsdict[key] = eval(key).__doc__ | |||
|
|||
with open("%s.py" % filename,"w") as f: | |||
keys = sorted(x for x in docsdict.keys() | |||
keys = sorted(x for x in docsdict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an improvement. Go ahead.
@@ -1286,7 +1286,8 @@ def do_open(self, http_class, req, **http_conn_args): | |||
h.set_debuglevel(self._debuglevel) | |||
|
|||
headers = dict(req.unredirected_hdrs) | |||
headers.update((k, v) for k, v in req.headers.items() if k not in headers) | |||
headers.update({k: v for k, v in req.headers.items() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave as-is. Don't create an unnecessary intermediate dictionary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I afraid that this change changed semantic.
Tools/gdb/libpython.py
Outdated
result = tuple(PyObjectPtr.from_pyobject_ptr(self[i]).proxyval(visited) | ||
for i in safe_range(int_from_int(self.field('ob_size')))) | ||
result = tuple([PyObjectPtr.from_pyobject_ptr(self[i]).proxyval(visited) | ||
for i in safe_range(int_from_int(self.field('ob_size')))]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The list comprehension is not necessary and doesn't improve the code. This should stay as-is.
When you're done making the requested changes, leave the comment: |
Thank you for your review @rhettinger. Note that this PR mainly just reverts unnecessary changes that may have unwanted effects. |
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
GH-5908 is a backport of this pull request to the 3.7 branch. |
…ments. (pythonGH-2624) (cherry picked from commit 3f2e6f1) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
https://bugs.python.org/issue30296