Skip to content

Commit 325c126

Browse files
committed
Support Vectorcall for _decimal.Decimal's
1 parent a000129 commit 325c126

3 files changed

Lines changed: 51 additions & 6 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Use AC vectorcall support for the :class:`decimal.Decimal`. This offers
2+
~1.15x speedup on creation of small instances.

‎Modules/_decimal/_decimal.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3309,6 +3309,7 @@ PyDec_FromObject(PyObject *v, PyObject *context)
33093309
}
33103310

33113311
/*[clinic input]
3312+
@vectorcall
33123313
@classmethod
33133314
_decimal.Decimal.__new__ as dec_new
33143315
@@ -3325,7 +3326,7 @@ trap is active.
33253326

33263327
static PyObject *
33273328
dec_new_impl(PyTypeObject *type, PyObject *value, PyObject *context)
3328-
/*[clinic end generated code: output=35f48a40c65625ba input=5f8a0892d3fcef80]*/
3329+
/*[clinic end generated code: output=35f48a40c65625ba input=0e5ca99183562cd9]*/
33293330
{
33303331
decimal_state *state = get_module_state_by_def(type);
33313332
CONTEXT_CHECK_VA(state, context);
@@ -6186,6 +6187,7 @@ static PyType_Slot dec_slots[] = {
61866187
{Py_tp_methods, dec_methods},
61876188
{Py_tp_getset, dec_getsets},
61886189
{Py_tp_new, dec_new},
6190+
{Py_tp_vectorcall, dec_vectorcall},
61896191

61906192
// Number protocol
61916193
{Py_nb_add, nm_mpd_qadd},

‎Modules/_decimal/clinic/_decimal.c.h‎

Lines changed: 46 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)