Skip to content

gh-73487: Convert _decimal to use Argument Clinic (part 7) - #138221

Merged
vstinner merged 12 commits into
python:mainfrom
skirpichev:ac-decimal/73487-pt7
Sep 18, 2025
Merged

gh-73487: Convert _decimal to use Argument Clinic (part 7)#138221
vstinner merged 12 commits into
python:mainfrom
skirpichev:ac-decimal/73487-pt7

Conversation

@skirpichev

@skirpichevskirpichev commented Aug 28, 2025

Copy link
Copy Markdown
Member
  • use "defining class" converter, where possible
  • convert Context._unsafe* to Argument Clinic

Use "defining class" converter, where possible.
@bedevere-appbedevere-appBot mentioned this pull request Aug 28, 2025
@skirpichev
skirpichev requested review from AA-Turner and serhiy-storchaka and removed request for AA-TurnerAugust 28, 2025 11:40
Comment threadModules/_decimal/_decimal.c
@skirpichev
skirpichev marked this pull request as ready for review August 28, 2025 14:23
Comment threadModules/_decimal/_decimal.c
Comment threadModules/_decimal/_decimal.c
Comment threadModules/_decimal/_decimal.c
Comment threadModules/_decimal/_decimal.c

@AA-TurnerAA-Turner 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.

Looks ok from a desk review, barring Serhiy's comments.

A

@AA-TurnerAA-Turner changed the title gh-73487: Convert _decimal to use Argument Clinic (part 7)gh-73487: Convert _decimal to use Argument Clinic (part 7)Sep 1, 2025

@serhiy-storchakaserhiy-storchaka 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.

Are there any uses of get_module_state_by_def() left?

Comment threadModules/_decimal/_decimal.c
Comment threadModules/_decimal/_decimal.c Outdated
Comment threadModules/_decimal/_decimal.c Outdated
Comment threadModules/_decimal/_decimal.c Outdated
@skirpichev

skirpichev commented Sep 2, 2025

Copy link
Copy Markdown
MemberAuthor

Are there any uses of get_module_state_by_def() left?

Yes, a lot:

$ git grep get_module_state_by_def Modules/_decimal
Modules/_decimal/_decimal.c:get_module_state_by_def(PyTypeObject *tp)
Modules/_decimal/_decimal.c: decimal_state *state = get_module_state_by_def(Py_TYPE(self));
Modules/_decimal/_decimal.c: decimal_state *state = get_module_state_by_def(Py_TYPE(self));
Modules/_decimal/_decimal.c: decimal_state *state = get_module_state_by_def(Py_TYPE(self));
Modules/_decimal/_decimal.c: decimal_state *state = get_module_state_by_def(Py_TYPE(self));
Modules/_decimal/_decimal.c: decimal_state *state = get_module_state_by_def(Py_TYPE(v));
Modules/_decimal/_decimal.c: decimal_state *state = get_module_state_by_def(Py_TYPE(self));
Modules/_decimal/_decimal.c: decimal_state *state = get_module_state_by_def(type);
Modules/_decimal/_decimal.c: decimal_state *state = get_module_state_by_def(type);
Modules/_decimal/_decimal.c: decimal_state *state = get_module_state_by_def(Py_TYPE(dec));
Modules/_decimal/_decimal.c: decimal_state *state = get_module_state_by_def(Py_TYPE(dec));
Modules/_decimal/_decimal.c: decimal_state *state = get_module_state_by_def(Py_TYPE(self));
Modules/_decimal/_decimal.c: decimal_state *state = get_module_state_by_def(Py_TYPE(self)); \
Modules/_decimal/_decimal.c: decimal_state *state = get_module_state_by_def(Py_TYPE(dec));
Modules/_decimal/_decimal.c: decimal_state *state = get_module_state_by_def(Py_TYPE(self));

I'll double check, some case could be converted to use "defining class" converter (e.g. _decimal.Decimal.as_tuple), but not all.

Edit: I think nothing left.

@skirpichev

Copy link
Copy Markdown
MemberAuthor

@serhiy-storchaka, do you think anything left to address issue?

@serhiy-storchakaserhiy-storchaka 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.

Minor question, and LGTM. 👍

Comment threadModules/_decimal/_decimal.c Outdated
Comment threadModules/_decimal/_decimal.c Outdated

@vstinnervstinner 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.

LGTM

@vstinner
vstinner merged commit b0a8073 into python:mainSep 18, 2025
43 checks passed
@vstinner

Copy link
Copy Markdown
Member

Merged, thanks.

@skirpichev
skirpichev deleted the ac-decimal/73487-pt7 branch September 18, 2025 14:09
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@skirpichev@vstinner@serhiy-storchaka@AA-Turner