mirror of
https://github.com/python/cpython.git
synced 2026-01-08 08:22:41 +00:00
gh-124872: Replace enter/exit events with "switched" (#124776)
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 for gh-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. I skipped 0 in the enum as a matter of practice. Skipping 0 makes it easier to troubleshoot when code forgets to set zeroed memory, and it aligns with best practices for other tools (e.g., https://protobuf.dev/programming-guides/dos-donts/#unspecified-enum).
This commit is contained in:
parent
e99650b80a
commit
843d28f59d
6 changed files with 114 additions and 114 deletions
|
|
@ -455,8 +455,8 @@ Modules/_testcapi/watchers.c - pyfunc_watchers -
|
|||
Modules/_testcapi/watchers.c - func_watcher_ids -
|
||||
Modules/_testcapi/watchers.c - func_watcher_callbacks -
|
||||
Modules/_testcapi/watchers.c - context_watcher_ids -
|
||||
Modules/_testcapi/watchers.c - num_context_object_enter_events -
|
||||
Modules/_testcapi/watchers.c - num_context_object_exit_events -
|
||||
Modules/_testcapi/watchers.c - context_switches -
|
||||
Modules/_testcapi/watchers.c add_context_watcher callbacks -
|
||||
Modules/_testcapimodule.c - BasicStaticTypes -
|
||||
Modules/_testcapimodule.c - num_basic_static_types_used -
|
||||
Modules/_testcapimodule.c - ContainerNoGC_members -
|
||||
|
|
|
|||
|
Can't render this file because it has a wrong number of fields in line 4.
|
Loading…
Add table
Add a link
Reference in a new issue