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-38205: replace get_small_int(ival) macro with a function version#16270

Closed
ghost wants to merge 1 commit into
masterpython/cpython:masterfrom
unknown repositoryCopy head branch name to clipboard
Closed

bpo-38205: replace get_small_int(ival) macro with a function version#16270
ghost wants to merge 1 commit into
masterpython/cpython:masterfrom
unknown repositoryCopy head branch name to clipboard

Conversation

@ghost

@ghost ghost commented Sep 19, 2019

Copy link
Copy Markdown

Use Py_UNREACHABLE() macro in a safe way.

https://bugs.python.org/issue38205

Use Py_UNREACHABLE() macro in a safe way.
Comment thread Objects/longobject.c

/* If use inline functions here, may lose performance due to
unnecessary type casting. */
#define IS_SMALL_INT(ival) (-NSMALLNEGINTS <= (ival) && (ival) < NSMALLPOSINTS)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Address STINNER Victor's advice:

Morever, if using a static inline function is causing issues, it would be nice to add a comment to explain why, so the issue will be avoided in the future.
https://bugs.python.org/issue37812#msg352670

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

" bpo-38205: replace get_small_int(ival) macro with a function version #16270 "

Wait, https://bugs.python.org/issue38205 is about a macro which became a function and then was revert to a macro again... I don't understand why you make it a function... one more time.

Py_UNREACHABLE() should be fixed, not longobject.c.

@bedevere-bot

Copy link
Copy Markdown

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@ghost

ghost commented Sep 19, 2019

Copy link
Copy Markdown
Author

I like the idea of implementing Py_UNREACHABLE() as a function.

+1, close this PR.

@ghost ghost closed this Sep 19, 2019
@ghost

ghost commented Sep 19, 2019

Copy link
Copy Markdown
Author

I don't understand why you make it a function... one more time.

The current code is not consistent:
If "preallocated small integers" enalbed, get_small_int(ival) is a function.
If "preallocated small integers" disabled, get_small_int(ival) is a macro.

@ghost ghost deleted the unreachable branch September 20, 2019 02:47
This pull request was closed.
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.

4 participants

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