mirror of
https://github.com/python/cpython.git
synced 2025-09-01 14:38:00 +00:00
Issue #14520: Add __sizeof__() method to the Decimal object.
This commit is contained in:
parent
f69aef747a
commit
e37f8b29fc
1 changed files with 14 additions and 0 deletions
|
@ -4340,6 +4340,19 @@ dec_reduce(PyObject *self, PyObject *dummy UNUSED)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* __sizeof__ */
|
||||||
|
static PyObject *
|
||||||
|
dec_sizeof(PyObject *v, PyObject *dummy UNUSED)
|
||||||
|
{
|
||||||
|
Py_ssize_t res;
|
||||||
|
|
||||||
|
res = sizeof(PyDecObject);
|
||||||
|
if (mpd_isdynamic_data(MPD(v))) {
|
||||||
|
res += MPD(v)->alloc * sizeof(mpd_uint_t);
|
||||||
|
}
|
||||||
|
return PyLong_FromSsize_t(res);
|
||||||
|
}
|
||||||
|
|
||||||
/* __trunc__ */
|
/* __trunc__ */
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dec_trunc(PyObject *self, PyObject *dummy UNUSED)
|
dec_trunc(PyObject *self, PyObject *dummy UNUSED)
|
||||||
|
@ -4503,6 +4516,7 @@ static PyMethodDef dec_methods [] =
|
||||||
{ "__floor__", dec_floor, METH_NOARGS, NULL },
|
{ "__floor__", dec_floor, METH_NOARGS, NULL },
|
||||||
{ "__trunc__", dec_trunc, METH_NOARGS, NULL },
|
{ "__trunc__", dec_trunc, METH_NOARGS, NULL },
|
||||||
{ "__complex__", dec_complex, METH_NOARGS, NULL },
|
{ "__complex__", dec_complex, METH_NOARGS, NULL },
|
||||||
|
{ "__sizeof__", dec_sizeof, METH_NOARGS, NULL },
|
||||||
|
|
||||||
{ NULL, NULL, 1 }
|
{ NULL, NULL, 1 }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue