Skip to content

gh-73487: Convert _decimal to use Argument Clinic (part 2) #137637

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

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address review: move to_integral_value around
  • Loading branch information
skirpichev committed Aug 11, 2025
commit d78a97f26de76ab6797760d1ca1acb4b3bb7c54a
54 changes: 27 additions & 27 deletions Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3919,20 +3919,22 @@ _decimal_Decimal_as_integer_ratio_impl(PyObject *self)
}

/*[clinic input]
_decimal.Decimal.to_integral
_decimal.Decimal.to_integral_value

rounding: object = None
context: object = None

Identical to the to_integral_value() method.
Round to the nearest integer without signaling Inexact or Rounded.

The to_integral() name has been kept for compatibility with older versions.
The rounding mode is determined by the rounding parameter if given, else by
the given context. If neither parameter is given, then the rounding mode of
the current default context is used.
[clinic start generated code]*/

static PyObject *
_decimal_Decimal_to_integral_impl(PyObject *self, PyObject *rounding,
PyObject *context)
/*[clinic end generated code: output=a0c7188686ee7f5c input=a57d62d1d29aed1b]*/
_decimal_Decimal_to_integral_value_impl(PyObject *self, PyObject *rounding,
PyObject *context)
/*[clinic end generated code: output=7301465765f48b6b input=5778168222cadf71]*/
{
PyObject *result;
uint32_t status = 0;
Expand Down Expand Up @@ -3966,6 +3968,25 @@ _decimal_Decimal_to_integral_impl(PyObject *self, PyObject *rounding,
return result;
}

/*[clinic input]
_decimal.Decimal.to_integral

rounding: object = None
context: object = None

Identical to the to_integral_value() method.

The to_integral() name has been kept for compatibility with older versions.
[clinic start generated code]*/

static PyObject *
_decimal_Decimal_to_integral_impl(PyObject *self, PyObject *rounding,
PyObject *context)
/*[clinic end generated code: output=a0c7188686ee7f5c input=a57d62d1d29aed1b]*/
{
return _decimal_Decimal_to_integral_value_impl(self, rounding, context);
}

/*[clinic input]
_decimal.Decimal.to_integral_exact

Expand Down Expand Up @@ -4017,27 +4038,6 @@ _decimal_Decimal_to_integral_exact_impl(PyObject *self, PyObject *rounding,
return result;
}

/*[clinic input]
_decimal.Decimal.to_integral_value

rounding: object = None
context: object = None

Round to the nearest integer without signaling Inexact or Rounded.

The rounding mode is determined by the rounding parameter if given, else by
the given context. If neither parameter is given, then the rounding mode of
the current default context is used.
[clinic start generated code]*/

static PyObject *
_decimal_Decimal_to_integral_value_impl(PyObject *self, PyObject *rounding,
PyObject *context)
/*[clinic end generated code: output=7301465765f48b6b input=5778168222cadf71]*/
{
return _decimal_Decimal_to_integral_impl(self, rounding, context);
}

static PyObject *
PyDec_AsFloat(PyObject *dec)
{
Expand Down
76 changes: 38 additions & 38 deletions Modules/_decimal/clinic/_decimal.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading