Skip to content

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Jul 7, 2017

@mention-bot
Copy link

@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.

@@ -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
Copy link
Contributor

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.

Copy link
Member Author

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)])
Copy link
Contributor

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)}
Copy link
Contributor

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)}
Copy link
Contributor

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')
Copy link
Contributor

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.

Copy link
Member Author

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])
Copy link
Contributor

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])
Copy link
Contributor

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
Copy link
Contributor

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()
Copy link
Contributor

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.

Copy link
Member Author

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.

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')))])
Copy link
Contributor

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.

@bedevere-bot
Copy link

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@serhiy-storchaka
Copy link
Member Author

Thank you for your review @rhettinger. Note that this PR mainly just reverts unnecessary changes that may have unwanted effects.

@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-5908 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 26, 2018
…ments. (pythonGH-2624)

(cherry picked from commit 3f2e6f1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington added a commit that referenced this pull request Feb 26, 2018
…ments. (GH-2624)

(cherry picked from commit 3f2e6f1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants