bpo-38870: refactor delimiting with context managers#17612
bpo-38870: refactor delimiting with context managers#17612pablogsal merged 6 commits intopython:masterfrom
Conversation
vstinner
left a comment
There was a problem hiding this comment.
Apart open questions to related to https://bugs.python.org/issue39069, this PR looks good to me.
@isidentical: Are you interested to measure the overhead of functools/enum imports/code? See https://bugs.python.org/issue39069#msg358498
|
Yes but currently I can only reply through mail because bpo logins with
google doesnt work. And if needed I can implement this lazy loading idea i
proposed earlier.
…On Mon, Dec 16, 2019 at 9:18 PM Victor Stinner ***@***.***> wrote:
***@***.**** commented on this pull request.
Apart open questions to related to https://bugs.python.org/issue39069,
this PR looks good to me.
@isidentical <https://github.com/isidentical>: Are you interested to
measure the overhead of functools/enum imports/code? See
https://bugs.python.org/issue39069#msg358498
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#17612?email_source=notifications&email_token=ALJKHQLANSE4ARV52LDEUKTQY7A6PA5CNFSM4J27S27KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCPK2EHA#pullrequestreview-332767772>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALJKHQJ63VEAVDM5HQZOEATQY7A6PANCNFSM4J27S27A>
.
|
|
Oh, looks like @pablogsal already assigned. |
Oh, I didn't know: I reported this issue at python/bugs.python.org#41 |
vstinner
left a comment
There was a problem hiding this comment.
I would prefer to only not delimit() if the delimiter is always written, like in a function call or item[index].
Lib/ast.py
Outdated
| self.fill(def_str) | ||
| self.traverse(node.args) | ||
| self.write(")") | ||
| with self.delimit("()"): |
There was a problem hiding this comment.
Wait. I'm not sure about this one. Are you going to omit parenthesis here sometimes?
The change is correct, but direct write() calls are maybe better.
Lib/ast.py
Outdated
| lambda: self.write(", "), write_item, zip(node.keys, node.values) | ||
| ) | ||
| self.write("}") | ||
| with self.delimit("{}"): |
There was a problem hiding this comment.
Same here, I'm not convince thta delimit() makes the code more readable.
Lib/ast.py
Outdated
| else: | ||
| self.interleave(lambda: self.write(", "), self.traverse, node.elts) | ||
| self.write(")") | ||
| with self.delimit("()"): |
Lib/ast.py
Outdated
| comma = True | ||
| self.traverse(e) | ||
| self.write(")") | ||
| with self.delimit("()"): |
Lib/ast.py
Outdated
| self.write("[") | ||
| self.traverse(node.slice) | ||
| self.write("]") | ||
| with self.delimit("[]"): |
Co-Authored-By: Victor Stinner <[email protected]>
|
@vstinner a general answer, I used delim in everywhere we are using brackets for the sake of consistency. If it looks better without them, I can just revert back in few places. |
vstinner
left a comment
There was a problem hiding this comment.
@pablogsal: Do you prefer to only use delim() when parenthesis can be optional, or are you fine with replacing all write(x) ... write(y) with "with delim(xy): ..."?
I am fine with replacing all |
Misc/NEWS.d/next/Library/2019-12-15-14-07-16.bpo-38870.8D28DB.rst
Outdated
Show resolved
Hide resolved
pablogsal
left a comment
There was a problem hiding this comment.
Almost there! I left some comments (will maybe leave more on a second pass).
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
…imiter, remove news entry
…to bpo-38870-delimit
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! @pablogsal: please review the changes made to this pull request. |
|
I am going to land this one to unblock the rest of the work. @vstinner, we can move the discussion about the readability of the code that you mention to the issue or another PR 😉 |
|
Thanks for the PR @isidentical! 🎉 |
|
|
I guess this is not related with my PR, does it? |
Is not, is a core dump on FreeBSD. This is going to be fun.... |
|
Thanks @isidentical and @pablogsal: the commit 4b3b122 is nice! I will to implement smarter parenthesis. @isidentical: ping me if you want a review on a "smarter parenthesis" PR, once you will have it written down (I didn't check if it's already the case). |
|
@pablogsal: "Is not, is a core dump on FreeBSD. This is going to be fun...." Did you open an issue to track this crash? |
Nop...I started vacation that day and I never did 😞 |
Yes I rebased it a top of this PR (and just fixed some conflicts due to other PR of mine), @vstinner. You can review |
|
Oh, it's the PR #17377, ok. |
…ythonGH-17612) Co-Authored-By: Victor Stinner <[email protected]> Co-authored-by: Pablo Galindo <[email protected]>
CC: @vstinner
https://bugs.python.org/issue38870