FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-111354: remove comparisons with enum values, variable reuse, unused imports in genobject.c by iritkatriel · Pull Request #111708 · python/cpython · GitHub

/ cpython Public

gh-111354: remove comparisons with enum values, variable reuse, unused imports in genobject.c - #111708

Merged
iritkatriel merged 9 commits into
python:mainfrom
iritkatriel:genobject
Nov 9, 2023
Merged

gh-111354: remove comparisons with enum values, variable reuse, unused imports in genobject.c#111708
iritkatriel merged 9 commits into
python:mainfrom
iritkatriel:genobject

Conversation

iritkatriel commented Nov 3, 2023
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

Tidies up genobject.c:

  • remove unused imports
  • inline a one-line function that is only called once
  • do not reuse the result variable for the arg
  • remove comparisons with frame state enum values

Reviewing individual commits might be easier.

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

A few comments

Comment thread Objects/genobject.c
/* Push arg onto the frame's value stack */
result = arg ? arg : Py_None;
_PyFrame_StackPush(frame, Py_NewRef(result));
PyObject *arg_obj = arg ? arg : Py_None;

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Would it make sense to require arg to be not NULL? This is a static function, so we know all the callers.
(Not necessarily in this PR, though)

Comment thread Objects/genobject.c Outdated
Comment thread Include/internal/pycore_frame.h Outdated
} PyFrameState;

#define FRAME_STATE_SUSPENDED(S) ((S) == FRAME_SUSPENDED || (S) == FRAME_SUSPENDED_YIELD_FROM)
#define FRAME_STATE_CLOSED(S) ((S) >= FRAME_COMPLETED)

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Does the state being FRAME_COMPLETED mean that it is closed?
Can't it be completed, but not closed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

There is no CLOSED state. There is COMPLETED and CLEARED. CLOSED is a new category of both. Maybe FINISHED is a better name for this.

iritkatriel merged commit 30ec968 into python:main Nov 9, 2023
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL