Skip to content

Conversation

@gnprice
Copy link
Contributor

@gnprice gnprice commented Aug 24, 2019

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

@aeros aeros left a comment

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

ghost commented Aug 24, 2019

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

5 participants