@@ -4288,23 +4288,16 @@ nm_##MPDFUNC(PyObject *self, PyObject *other) \
4288
4288
/* Boolean function without a context arg. */
4289
4289
#define Dec_BoolFunc (MPDFUNC ) \
4290
4290
static PyObject * \
4291
- dec_##MPDFUNC(PyObject *self, PyObject *Py_UNUSED(dummy)) \
4291
+ dec_##MPDFUNC(PyObject *self) \
4292
4292
{ \
4293
4293
return MPDFUNC(MPD(self)) ? incr_true() : incr_false(); \
4294
4294
}
4295
4295
4296
4296
/* Boolean function with an optional context arg. */
4297
4297
#define Dec_BoolFuncVA (MPDFUNC ) \
4298
4298
static PyObject * \
4299
- dec_##MPDFUNC(PyObject *self, PyObject *args, PyObject *kwds ) \
4299
+ dec_##MPDFUNC(PyObject *self, PyObject *context ) \
4300
4300
{ \
4301
- static char *kwlist[] = {"context", NULL}; \
4302
- PyObject *context = Py_None; \
4303
- \
4304
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O", kwlist, \
4305
- &context)) { \
4306
- return NULL; \
4307
- } \
4308
4301
decimal_state *state = get_module_state_by_def(Py_TYPE(self)); \
4309
4302
CONTEXT_CHECK_VA(state, context); \
4310
4303
\
@@ -4395,19 +4388,11 @@ dec_##MPDFUNC(PyObject *self, PyObject *other, PyObject *context)\
4395
4388
/* Ternary function with an optional context arg. */
4396
4389
#define Dec_TernaryFuncVA (MPDFUNC ) \
4397
4390
static PyObject * \
4398
- dec_##MPDFUNC(PyObject *self, PyObject *args , PyObject *kwds ) \
4391
+ dec_##MPDFUNC(PyObject *self, PyObject *other , PyObject *third, PyObject *context ) \
4399
4392
{ \
4400
- static char *kwlist[] = {"other", "third", "context", NULL}; \
4401
- PyObject *other, *third; \
4402
4393
PyObject *a, *b, *c; \
4403
4394
PyObject *result; \
4404
- PyObject *context = Py_None; \
4405
4395
uint32_t status = 0; \
4406
- \
4407
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|O", kwlist, \
4408
- &other, &third, &context)) { \
4409
- return NULL; \
4410
- } \
4411
4396
decimal_state *state = get_module_state_by_def(Py_TYPE(self)); \
4412
4397
CONTEXT_CHECK_VA(state, context); \
4413
4398
CONVERT_TERNOP_RAISE(&a, &b, &c, self, other, third, context); \
@@ -4859,6 +4844,30 @@ _decimal_Decimal_remainder_near_impl(PyObject *self, PyObject *other,
4859
4844
/* Ternary arithmetic functions, optional context arg */
4860
4845
Dec_TernaryFuncVA (mpd_qfma )
4861
4846
4847
+ /*[clinic input]
4848
+ _decimal.Decimal.fma
4849
+
4850
+ other: object
4851
+ third: object
4852
+ context: object = None
4853
+
4854
+ Fused multiply-add.
4855
+
4856
+ Return self*other+third with no rounding of the intermediate product
4857
+ self*other.
4858
+
4859
+ >>> Decimal(2).fma(3, 5)
4860
+ Decimal('11')
4861
+ [clinic start generated code]*/
4862
+
4863
+ static PyObject *
4864
+ _decimal_Decimal_fma_impl (PyObject * self , PyObject * other , PyObject * third ,
4865
+ PyObject * context )
4866
+ /*[clinic end generated code: output=74a82b984e227b69 input=48f9aec6f389227a]*/
4867
+ {
4868
+ return dec_mpd_qfma (self , other , third , context );
4869
+ }
4870
+
4862
4871
/* Boolean functions, no context arg */
4863
4872
Dec_BoolFunc (mpd_iscanonical )
4864
4873
Dec_BoolFunc (mpd_isfinite )
@@ -4869,10 +4878,154 @@ Dec_BoolFunc(mpd_issnan)
4869
4878
Dec_BoolFunc (mpd_issigned )
4870
4879
Dec_BoolFunc (mpd_iszero )
4871
4880
4881
+ /*[clinic input]
4882
+ _decimal.Decimal.is_canonical
4883
+
4884
+ Return True if the argument is canonical and False otherwise.
4885
+
4886
+ Currently, a Decimal instance is always canonical, so this operation
4887
+ always returns True.
4888
+ [clinic start generated code]*/
4889
+
4890
+ static PyObject *
4891
+ _decimal_Decimal_is_canonical_impl (PyObject * self )
4892
+ /*[clinic end generated code: output=b29668684f45443e input=b3b3e6878ccf40b8]*/
4893
+ {
4894
+ return dec_mpd_iscanonical (self );
4895
+ }
4896
+
4897
+ /*[clinic input]
4898
+ _decimal.Decimal.is_finite
4899
+
4900
+ Return True if the argument is a finite number, and False otherwise.
4901
+ [clinic start generated code]*/
4902
+
4903
+ static PyObject *
4904
+ _decimal_Decimal_is_finite_impl (PyObject * self )
4905
+ /*[clinic end generated code: output=537306fbfc9131f8 input=e9b8b5866704bae6]*/
4906
+ {
4907
+ return dec_mpd_isfinite (self );
4908
+ }
4909
+
4910
+ /*[clinic input]
4911
+ _decimal.Decimal.is_infinite
4912
+
4913
+ Return True if the argument is infinite, and False otherwise.
4914
+ [clinic start generated code]*/
4915
+
4916
+ static PyObject *
4917
+ _decimal_Decimal_is_infinite_impl (PyObject * self )
4918
+ /*[clinic end generated code: output=31b775ff28f05ce2 input=8f3937a790ee4ec2]*/
4919
+ {
4920
+ return dec_mpd_isinfinite (self );
4921
+ }
4922
+
4923
+ /*[clinic input]
4924
+ _decimal.Decimal.is_nan
4925
+
4926
+ Return True if the argument is a (quiet or signaling) NaN and False otherwise.
4927
+ [clinic start generated code]*/
4928
+
4929
+ static PyObject *
4930
+ _decimal_Decimal_is_nan_impl (PyObject * self )
4931
+ /*[clinic end generated code: output=b704e8b49a164388 input=fadb52a8da692c5b]*/
4932
+ {
4933
+ return dec_mpd_isnan (self );
4934
+ }
4935
+
4936
+ /*[clinic input]
4937
+ _decimal.Decimal.is_qnan
4938
+
4939
+ Return True if the argument is a quiet NaN, and False otherwise.
4940
+ [clinic start generated code]*/
4941
+
4942
+ static PyObject *
4943
+ _decimal_Decimal_is_qnan_impl (PyObject * self )
4944
+ /*[clinic end generated code: output=85b5241f43798376 input=00485f3c3cfae0af]*/
4945
+ {
4946
+ return dec_mpd_isqnan (self );
4947
+ }
4948
+
4949
+ /*[clinic input]
4950
+ _decimal.Decimal.is_snan
4951
+
4952
+ Return True if the argument is a signaling NaN and False otherwise.
4953
+ [clinic start generated code]*/
4954
+
4955
+ static PyObject *
4956
+ _decimal_Decimal_is_snan_impl (PyObject * self )
4957
+ /*[clinic end generated code: output=50de9ec6507e4a4f input=f3b0f8592c921879]*/
4958
+ {
4959
+ return dec_mpd_issnan (self );
4960
+ }
4961
+
4962
+ /*[clinic input]
4963
+ _decimal.Decimal.is_signed
4964
+
4965
+ Return True if the argument has a negative sign and False otherwise.
4966
+
4967
+ Note that both zeros and NaNs can carry signs.
4968
+ [clinic start generated code]*/
4969
+
4970
+ static PyObject *
4971
+ _decimal_Decimal_is_signed_impl (PyObject * self )
4972
+ /*[clinic end generated code: output=8ec7bc85d8e755e4 input=97c3437ab5dffecc]*/
4973
+ {
4974
+ return dec_mpd_issigned (self );
4975
+ }
4976
+
4977
+ /*[clinic input]
4978
+ _decimal.Decimal.is_zero
4979
+
4980
+ Return True if the argument is a (positive or negative) zero and False otherwise.
4981
+ [clinic start generated code]*/
4982
+
4983
+ static PyObject *
4984
+ _decimal_Decimal_is_zero_impl (PyObject * self )
4985
+ /*[clinic end generated code: output=2d87ea1b15879112 input=35de901ce2554a4d]*/
4986
+ {
4987
+ return dec_mpd_iszero (self );
4988
+ }
4989
+
4872
4990
/* Boolean functions, optional context arg */
4873
4991
Dec_BoolFuncVA (mpd_isnormal )
4874
4992
Dec_BoolFuncVA (mpd_issubnormal )
4875
4993
4994
+ /*[clinic input]
4995
+ _decimal.Decimal.is_normal
4996
+
4997
+ context: object = None
4998
+
4999
+ Return True if the argument is a normal number and False otherwise.
5000
+
5001
+ Normal number is a finite nonzero number, which is not subnormal.
5002
+ [clinic start generated code]*/
5003
+
5004
+ static PyObject *
5005
+ _decimal_Decimal_is_normal_impl (PyObject * self , PyObject * context )
5006
+ /*[clinic end generated code: output=40cc429d388eb464 input=9def7316be59ce4e]*/
5007
+ {
5008
+ return dec_mpd_isnormal (self , context );
5009
+ }
5010
+
5011
+ /*[clinic input]
5012
+ _decimal.Decimal.is_subnormal
5013
+
5014
+ context: object = None
5015
+
5016
+ Return True if the argument is subnormal, and False otherwise.
5017
+
5018
+ A number is subnormal if it is non-zero, finite, and has an adjusted
5019
+ exponent less than Emin.
5020
+ [clinic start generated code]*/
5021
+
5022
+ static PyObject *
5023
+ _decimal_Decimal_is_subnormal_impl (PyObject * self , PyObject * context )
5024
+ /*[clinic end generated code: output=6f7d422b1f387d7f input=08e90e1d9fb87300]*/
5025
+ {
5026
+ return dec_mpd_issubnormal (self , context );
5027
+ }
5028
+
4876
5029
/* Unary functions, no context arg */
4877
5030
4878
5031
/*[clinic input]
@@ -5804,21 +5957,21 @@ static PyMethodDef dec_methods [] =
5804
5957
_DECIMAL_DECIMAL_REMAINDER_NEAR_METHODDEF
5805
5958
5806
5959
/* Ternary arithmetic functions, optional context arg */
5807
- { "fma" , _PyCFunction_CAST ( dec_mpd_qfma ), METH_VARARGS | METH_KEYWORDS , doc_fma },
5960
+ _DECIMAL_DECIMAL_FMA_METHODDEF
5808
5961
5809
5962
/* Boolean functions, no context arg */
5810
- { "is_canonical" , dec_mpd_iscanonical , METH_NOARGS , doc_is_canonical },
5811
- { "is_finite" , dec_mpd_isfinite , METH_NOARGS , doc_is_finite },
5812
- { "is_infinite" , dec_mpd_isinfinite , METH_NOARGS , doc_is_infinite },
5813
- { "is_nan" , dec_mpd_isnan , METH_NOARGS , doc_is_nan },
5814
- { "is_qnan" , dec_mpd_isqnan , METH_NOARGS , doc_is_qnan },
5815
- { "is_snan" , dec_mpd_issnan , METH_NOARGS , doc_is_snan },
5816
- { "is_signed" , dec_mpd_issigned , METH_NOARGS , doc_is_signed },
5817
- { "is_zero" , dec_mpd_iszero , METH_NOARGS , doc_is_zero },
5963
+ _DECIMAL_DECIMAL_IS_CANONICAL_METHODDEF
5964
+ _DECIMAL_DECIMAL_IS_FINITE_METHODDEF
5965
+ _DECIMAL_DECIMAL_IS_INFINITE_METHODDEF
5966
+ _DECIMAL_DECIMAL_IS_NAN_METHODDEF
5967
+ _DECIMAL_DECIMAL_IS_QNAN_METHODDEF
5968
+ _DECIMAL_DECIMAL_IS_SNAN_METHODDEF
5969
+ _DECIMAL_DECIMAL_IS_SIGNED_METHODDEF
5970
+ _DECIMAL_DECIMAL_IS_ZERO_METHODDEF
5818
5971
5819
5972
/* Boolean functions, optional context arg */
5820
- { "is_normal" , _PyCFunction_CAST ( dec_mpd_isnormal ), METH_VARARGS | METH_KEYWORDS , doc_is_normal },
5821
- { "is_subnormal" , _PyCFunction_CAST ( dec_mpd_issubnormal ), METH_VARARGS | METH_KEYWORDS , doc_is_subnormal },
5973
+ _DECIMAL_DECIMAL_IS_NORMAL_METHODDEF
5974
+ _DECIMAL_DECIMAL_IS_SUBNORMAL_METHODDEF
5822
5975
5823
5976
/* Unary functions, no context arg */
5824
5977
_DECIMAL_DECIMAL_ADJUSTED_METHODDEF
0 commit comments