Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
+2
  • Loading branch information
skirpichev committed Aug 21, 2025
commit 94537e1cf350753415206b8f37cdd665394faa96
40 changes: 30 additions & 10 deletions Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -6112,18 +6112,11 @@ static PyType_Spec dec_spec = {
* The actual MPDFUNC does NOT take a context arg.
*/
#define DecCtx_BinaryFunc_NO_CTX(MPDFUNC) \
static PyObject * \
ctx_##MPDFUNC(PyObject *context, PyObject *args) \
{ \
PyObject *v, *w; \
PyObject *a, *b; \
PyObject *result; \
\
if (!PyArg_ParseTuple(args, "OO", &v, &w)) { \
return NULL; \
} \
\
CONVERT_BINOP_RAISE(&a, &b, v, w, context); \
CONVERT_BINOP_RAISE(&a, &b, x, y, context); \
decimal_state *state = \
get_module_state_from_ctx(context); \
if ((result = dec_alloc(state)) == NULL) { \
Expand Down Expand Up @@ -6945,7 +6938,34 @@ ctx_mpd_to_eng(PyObject *context, PyObject *v)
}

/* Functions with two decimal arguments */

/*[clinic input]
_decimal.Context.compare_total

self as context: self
x: object
y: object
/

Compare x and y using their abstract representation.
[clinic start generated code]*/

static PyObject *
_decimal_Context_compare_total_impl(PyObject *context, PyObject *x,
PyObject *y)
/*[clinic end generated code: output=a9299ef125fb2245 input=020b30c9bc2ea2c6]*/
DecCtx_BinaryFunc_NO_CTX(mpd_compare_total)

/*[clinic input]
_decimal.Context.compare_total_mag = _decimal.Context.compare_total

Compare x and y using their abstract representation, ignoring sign.
[clinic start generated code]*/

static PyObject *
_decimal_Context_compare_total_mag_impl(PyObject *context, PyObject *x,
PyObject *y)
/*[clinic end generated code: output=7c376de9f94feeaf input=2b982e69f932dcb2]*/
DecCtx_BinaryFunc_NO_CTX(mpd_compare_total_mag)

static PyObject *
Expand Down Expand Up @@ -7143,8 +7163,8 @@ static PyMethodDef context_methods [] =
{ "to_eng_string", ctx_mpd_to_eng, METH_O, doc_ctx_to_eng_string },

/* Functions with two decimal arguments */
{ "compare_total", ctx_mpd_compare_total, METH_VARARGS, doc_ctx_compare_total },
{ "compare_total_mag", ctx_mpd_compare_total_mag, METH_VARARGS, doc_ctx_compare_total_mag },
_DECIMAL_CONTEXT_COMPARE_TOTAL_METHODDEF
_DECIMAL_CONTEXT_COMPARE_TOTAL_MAG_METHODDEF
{ "copy_sign", ctx_mpd_qcopy_sign, METH_VARARGS, doc_ctx_copy_sign },
_DECIMAL_CONTEXT_LOGICAL_AND_METHODDEF
_DECIMAL_CONTEXT_LOGICAL_OR_METHODDEF
Expand Down
64 changes: 63 additions & 1 deletion Modules/_decimal/clinic/_decimal.c.h

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

10 changes: 0 additions & 10 deletions Modules/_decimal/docstrings.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ PyDoc_STRVAR(doc_ctx_canonical,
Return a new instance of x.\n\
\n");

PyDoc_STRVAR(doc_ctx_compare_total,
"compare_total($self, x, y, /)\n--\n\n\
Compare x and y using their abstract representation.\n\
\n");

PyDoc_STRVAR(doc_ctx_compare_total_mag,
"compare_total_mag($self, x, y, /)\n--\n\n\
Compare x and y using their abstract representation, ignoring sign.\n\
\n");

PyDoc_STRVAR(doc_ctx_copy_abs,
"copy_abs($self, x, /)\n--\n\n\
Return a copy of x with the sign set to 0.\n\
Expand Down
Loading