Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

gh-124872: Replace enter/exit events with "switched"#124776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
1st1 merged 1 commit intopython:mainfromrhansen:gh-119333-context-switched
Oct 14, 2024

Conversation

@rhansen
Copy link
Contributor

@rhansenrhansen commentedSep 30, 2024
edited
Loading

Users want to know when the current context switches to a different context object. Right now this happens when and only when a context is entered or exited, so the enter and exit events are synonymous with "switched". However, if the changes proposed forgh-99633 are implemented, the current context will also switch for reasons other than context enter or exit. Since users actually care about context switches and not enter or exit, replace the enter and exit events with a single switched event.

The former exit event was emitted just before exiting the context. The new switched event is emitted after the context is exited to match the semantics users expect of an event with a past-tense name. If users need the ability to clean up before the switch takes effect, another event type can be added in the future. It is not added here because YAGNI.

This commit amends a feature that is new to v3.14 so I did not include a NEWS blurb (theexisting blurb should suffice).

cc@fried


📚 Documentation preview 📚:https://cpython-previews--124776.org.readthedocs.build/

@rhansenrhansenforce-pushed thegh-119333-context-switched branch 4 times, most recently from8242dce to7606b67CompareOctober 1, 2024 23:23
@rhansenrhansen changed the titlegh-119333, gh-99633: Replace enter/exit events with "switched"gh-124872: Replace enter/exit events with "switched"Oct 1, 2024
@rhansenrhansenforce-pushed thegh-119333-context-switched branch 3 times, most recently frome68cb7f tod04d9c0CompareOctober 2, 2024 22:04
@rhansenrhansenforce-pushed thegh-119333-context-switched branch fromd04d9c0 tof3f17b3CompareOctober 10, 2024 08:45
Users want to know when the current context switches to a differentcontext object.  Right now this happens when and only when a contextis entered or exited, so the enter and exit events are synonymous with"switched".  However, if the changes proposed forpythongh-99633 areimplemented, the current context will also switch for reasons otherthan context enter or exit.  Since users actually care about contextswitches and not enter or exit, replace the enter and exit events witha single switched event.The former exit event was emitted just before exiting the context.The new switched event is emitted after the context is exited to matchthe semantics users expect of an event with a past-tense name.  Ifusers need the ability to clean up before the switch takes effect,another event type can be added in the future.  It is not added herebecause YAGNI.I skipped 0 in the enum as a matter of practice.  Skipping 0 makes iteasier to troubleshoot when code forgets to set zeroed memory, and italigns with best practices for other tools (e.g.,https://protobuf.dev/programming-guides/dos-donts/#unspecified-enum).
@rhansenrhansenforce-pushed thegh-119333-context-switched branch fromb4cff77 tod898525CompareOctober 12, 2024 21:40
@rhansenrhansen marked this pull request as ready for reviewOctober 12, 2024 21:42
@ZeroIntensity
Copy link
Member

This is sort of reviewed already, per discussion in the original issue, so I'm approving it.

Copy link
Contributor

@friedfried left a comment

Choose a reason for hiding this comment

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

LGTM on behavioral changes.@1st1 as requested

1st1 reacted with rocket emoji
casePy_CONTEXT_SWITCHED:
return"Py_CONTEXT_SWITCHED";
default:
return"?";
Copy link
Member

Choose a reason for hiding this comment

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

Actually, please you usePy_UNREACHABLE() here

Copy link
Contributor

Choose a reason for hiding this comment

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

The ? was@gvanrossum idea in my pr.

Copy link
Member

Choose a reason for hiding this comment

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

Hm, alright, I'm not gonna overturn Guido's review :) I'll push this as is.

@1st11st1 merged commit843d28f intopython:mainOct 14, 2024
42 checks passed
@1st1
Copy link
Member

Thank you Richard!

rhansen reacted with heart emoji

@rhansenrhansen deleted the gh-119333-context-switched branchOctober 15, 2024 00:03
Eclips4 added a commit to Eclips4/cpython that referenced this pull requestOct 15, 2024
Eclips4 added a commit to Eclips4/cpython that referenced this pull requestOct 15, 2024
Eclips4 pushed a commit to Eclips4/cpython that referenced this pull requestOct 16, 2024
…4776)Users want to know when the current context switches to a differentcontext object.  Right now this happens when and only when a contextis entered or exited, so the enter and exit events are synonymous with"switched".  However, if the changes proposed forpythongh-99633 areimplemented, the current context will also switch for reasons otherthan context enter or exit.  Since users actually care about contextswitches and not enter or exit, replace the enter and exit events witha single switched event.The former exit event was emitted just before exiting the context.The new switched event is emitted after the context is exited to matchthe semantics users expect of an event with a past-tense name.  Ifusers need the ability to clean up before the switch takes effect,another event type can be added in the future.  It is not added herebecause YAGNI.I skipped 0 in the enum as a matter of practice.  Skipping 0 makes iteasier to troubleshoot when code forgets to set zeroed memory, and italigns with best practices for other tools (e.g.,https://protobuf.dev/programming-guides/dos-donts/#unspecified-enum).
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@friedfriedfried approved these changes

@1st11st11st1 approved these changes

@picnixzpicnixzpicnixz left review comments

@ZeroIntensityZeroIntensityZeroIntensity approved these changes

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@rhansen@ZeroIntensity@1st1@fried@picnixz

[8]ページ先頭

©2009-2025 Movatter.jp