-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-103092: Isolate _decimal
#103381
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
gh-103092: Isolate _decimal
#103381
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
60902dd
Establish global state
erlend-aasland fa06750
Adapt PyDecContextManager_Type to heap type and add it to state
erlend-aasland f19c14c
fixup! Adapt PyDecContextManager_Type to heap type and add it to state
erlend-aasland cde5da9
Adapt PyDecContext_Type to heap type and add it to state
erlend-aasland 90955ab
Adapt PyDecSignalDictMixin_Type to heap type and add it to state
erlend-aasland ae2ac48
fixup! Adapt PyDecSignalDictMixin_Type to heap type and add it to state
erlend-aasland eee3ef7
Adapt and add PyDec_Type & PyDecSignalDict_Type
erlend-aasland f9c3573
Add DecimalTuple to state
erlend-aasland 57316db
fixup! Add DecimalTuple to state
erlend-aasland 30e4128
Add DecimalException to state
erlend-aasland f92e385
fixup! Add DecimalException to state
erlend-aasland 8b6c0c7
Add `basic_context_template` to state
CharlieZhao95 2ea6d98
Add `extended_context_template` to state
CharlieZhao95 7bf48be
Add `default_context_template` to state
CharlieZhao95 cd41d2c
Add context var to state
CharlieZhao95 44b0843
fixup! Add default_context_template to state
CharlieZhao95 db7b988
Add round_map to state
CharlieZhao95 86170a2
Add `Rational` and `SignalTuple` to state
CharlieZhao95 bc8df8f
Add external C-API functions to state
CharlieZhao95 4ff1074
port _decimal module to multi-initialization
CharlieZhao95 8fba9e8
Move global state to module state
CharlieZhao95 be7fa2a
Add `signal_map` to state to fix error in `decimal.Context`.
CharlieZhao95 b130f56
solve warnings and remove redundant code
CharlieZhao95 39fe618
Merge branch 'main' into isolate-decimal
erlend-aasland a81da37
remove NDEBUG and static-local variables
CharlieZhao95 6638ca7
Add a NEWS entry.
CharlieZhao95 7b05a94
Merge remote-tracking branch 'upstream/main' into isolate-decimal
CharlieZhao95 68473a0
Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
CharlieZhao95 e00dc55
Merge branch 'main' into isolate-decimal
kumaraditya303 58f0049
Update Modules/_decimal/_decimal.c
CharlieZhao95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
remove NDEBUG and static-local variables
- Loading branch information
commit a81da377c43d8a868f0de5cf8407403b01d71f6b
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,7 +227,7 @@ incr_false(void) | |
static inline void | ||
signal_map_init(decimal_state *state) | ||
{ | ||
static DecCondMap signal_map[] = { | ||
const DecCondMap signal_map[] = { | ||
{"InvalidOperation", "decimal.InvalidOperation", MPD_IEEE_Invalid_operation, NULL}, | ||
{"FloatOperation", "decimal.FloatOperation", MPD_Float_operation, NULL}, | ||
{"DivisionByZero", "decimal.DivisionByZero", MPD_Division_by_zero, NULL}, | ||
|
@@ -1422,10 +1422,8 @@ context_repr(PyDecContextObject *self) | |
char traps[MPD_MAX_SIGNAL_LIST]; | ||
int n, mem; | ||
|
||
#ifdef NDEBUG | ||
decimal_state *state = get_module_state_by_def(Py_TYPE(self)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. guard with |
||
assert(PyDecContext_Check(state, self)); | ||
#endif | ||
ctx = CTX(self); | ||
|
||
mem = MPD_MAX_SIGNAL_LIST; | ||
|
@@ -2368,9 +2366,7 @@ PyDecType_FromFloatExact(PyTypeObject *type, PyObject *v, | |
mpd_context_t maxctx; | ||
decimal_state *state = get_module_state_by_def(type); | ||
|
||
#ifdef NDEBUG | ||
assert(PyType_IsSubtype(type, state->PyDec_Type)); | ||
#endif | ||
|
||
if (PyLong_Check(v)) { | ||
return PyDecType_FromLongExact(type, v, context); | ||
|
@@ -4667,9 +4663,7 @@ dec_richcompare(PyObject *v, PyObject *w, int op) | |
int r; | ||
decimal_state *state = find_state_left_or_right(v, w); | ||
|
||
#ifdef NDEBUG | ||
assert(PyDec_Check(state, v)); | ||
#endif | ||
|
||
CURRENT_CONTEXT(state, context); | ||
CONVERT_BINOP_CMP(&a, &b, v, w, op, context); | ||
|
@@ -5870,13 +5864,7 @@ _decimal_exec(PyObject *m) | |
mpd_reallocfunc = PyMem_Realloc; | ||
mpd_callocfunc = mpd_callocfunc_em; | ||
mpd_free = PyMem_Free; | ||
|
||
static int minalloc_is_set = 0; | ||
if (minalloc_is_set == 0) { | ||
// FIXME: mpd_setminalloc may be used only once at program start. | ||
mpd_setminalloc(_Py_DEC_MINALLOC); | ||
minalloc_is_set = 1; | ||
} | ||
mpd_setminalloc(_Py_DEC_MINALLOC); | ||
|
||
decimal_state *state = get_module_state(m); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.