GeezerVison is showing github.com — Isolate the `_decimal` extension module · Issue #106078 · python/cpython
Isolate the _decimal extension module #106078DescriptionThis issue is used to track the PRs split from gh-103092. Isolate the _decimal extension module by:
- Establish a global module state and convert static types to heap types
- Move other global static variables to the global module state(possibly multiple PRs)
- DecimalException
- basic_context_template
- tls_context_key
- cached_context
- current_context_var
- default_context_template
- extended_context_template
- round_map
- Rational
- SignalTuple
- External C-API functions
- Convert the global module state to true module state
- signal_map
- cond_map
- convert global state to module state
See original issue Isolate Stdlib Extension Modules and PEP-687 for details.
Linked PRs
Activityerlend-aasland commented on Jun 29, 2023 CharlieZhao95 commented on Jun 29, 2023 ContributorAuthor More actions
What is your next step, @CharlieZhao95?
I think next we can move the remaining static global PyObject to global_state:
- DecimalException
- basic_context_template
- current_context_var
- default_context_template
- extended_context_template
- round_map
- Rational
- SignalTuple
- External C-API functions
This shouldn't be too complicated. The only question is whether we should move these external-API functions, which simply hold function pointers used by numeric types, such as nb_multiply, nb_floor_divide and so on. They will not change during the lifecycle of the program. erlend-aasland commented on Jun 29, 2023 Pick the low-hanging fruit first. It is better with multiple small PRs than one big. Reacted by Charlie Zhao and Alex Waygood CharlieZhao95 commented on Jun 29, 2023 ContributorAuthor More actions
Pick the low-hanging fruit first. It is better with multiple small PRs than one big.
Okay! let's go step by step. I will put the objects listed above into multiple small PRs. Reacted by Erlend E. Aasland added 4 commits that reference this issue on Jul 3, 2023gh-106078: Move `context template` to decimal module global state (#1… gh-106078: Move static objects related to `CONTEXTVAR` to the decimal… gh-106078: Move static variables initialized once to decimal module g… gh-106078: Move external C-API functions to decimal module global sta… CharlieZhao95 commented on Jul 11, 2023 ContributorAuthor More actions The second stage has been completed. All documented static variables are moved to the global state. Thanks for review! @erlend-aasland @kumaraditya303
Based on the experience of the original PR, we should also move the signal_map into the module state before converting the global state. This array of structures contains potentially global variables(ex).
typedef struct {
const char *name; /* condition or signal name */
const char *fqname; /* fully qualified name */
uint32_t flag; /* libmpdec flag */
PyObject *ex; /* corresponding exception */
} DecCondMap;
static DecCondMap signal_map[] = {
...
}
IMO, the next stage should be:
- Move
signal_map to global state
- Convert the global module state to true module state
How about opening a draft PR (convert the global module) first? This will allow us to see failed test cases raised by signal_map more clearly. Or do I just start moving signal_map into global state? erlend-aasland commented on Jul 11, 2023
How about opening a draft PR (convert the global module) first? This will allow us to see failed test cases raised by signal_map more clearly. Or do I just start moving signal_map into global state?
FTR, I often open PRs on my own fork to check CI issues, so that I won't pollute the CPython PR list too much.
Also: I'll be away for the rest of summer, so my response time will probably be slower than usual, just so you know :) CharlieZhao95 commented on Jul 14, 2023 Author show commentMore actions erlend-aasland commented on Jul 28, 2023 Reacted by Charlie Zhao, Kumar Aditya and Kirill Podoprigora added a commit that references this issue on Oct 6, 2023gh-106078: Suppress the warning caused by multi-phase initialization …
MetadataMetadataStatusShow more project fields
DevelopmentNo branches or pull requestsIssue actions
|