Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-37812: Expand CHECK_BINOP to make an (almost) explicit return.#15448

Closed
gnprice wants to merge 2 commits into
python:masterpython/cpython:masterfrom
gnprice:pr-explicit-return-notimplementedgnprice/cpython:pr-explicit-return-notimplementedCopy head branch name to clipboard
Closed

bpo-37812: Expand CHECK_BINOP to make an (almost) explicit return.#15448
gnprice wants to merge 2 commits into
python:masterpython/cpython:masterfrom
gnprice:pr-explicit-return-notimplementedgnprice/cpython:pr-explicit-return-notimplementedCopy head branch name to clipboard

Conversation

@gnprice

@gnprice gnprice commented Aug 24, 2019

Copy link
Copy Markdown
Contributor

OK, Py_RETURN_NOTIMPLEMENTED isn't quite an explicit return
statement either... but it does have the word "return" in there.
That makes it a lot easier to notice when scanning through the code,
and once noticed, it makes it unambiguous that what it's going to do
is return.

https://bugs.python.org/issue37812

OK, `Py_RETURN_NOTIMPLEMENTED` isn't quite an explicit `return`
statement either... but it does have the word "return" in there.
That makes it a lot easier to notice when scanning through the code,
and once noticed, it makes it unambiguous that what it's going to do
is return.

@aeros aeros left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @gnprice.

Overall, I agree with the changes, I definitely prefer the more explicit pseudo returns. As far as I can tell, this does not modify the logic (unlike the proposed PR for CHECK_SMALL_INT)

/cc @rhettinger

I just have a minor suggestion for the news entry:

@@ -0,0 +1,3 @@
The ``CHECK_BINOP`` macro inside :file:`Object/longobject.c` has been
replaced with an explicit :c:macro:`Py_RETURN_NOTIMPLEMENTED` at each call
site, inside an ordinary ``if``.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the Misc/NEWS entry could be a bit more succinct:

The ``CHECK_BINOP`` macro in :file:`Object/longobject.c` has been replaced by 
using explicit :c:macro:`Py_RETURN_NOTIMPLEMENTED`s.

For more details, readers can look at the changes made to longobject.c.

@aeros aeros added the type-feature A feature request or enhancement label Aug 24, 2019
@ghost

ghost commented Aug 24, 2019

Copy link
Copy Markdown

If change the check order:

-    CHECK_BINOP(a, b);
+    CHECK_BINOP(b, a);

Will it be a little bit faster when the check fails?
I think when it fails, usually the second operand is wrong.

@rhettinger

Copy link
Copy Markdown
Contributor

See comments on the tracker. I'd like to not churn correct code for minor aesthetic reasons.

@rhettinger rhettinger closed this Aug 24, 2019
@gnprice gnprice deleted the pr-explicit-return-notimplemented branch August 24, 2019 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.