cpython: 010aa5d955ac (original) (raw)
Mercurial > cpython
changeset 76198:010aa5d955ac
Issue #14520: Add __sizeof__() method to the Decimal object. [#14520]
Stefan Krah skrah@bytereef.org | |
---|---|
date | Mon, 09 Apr 2012 21:27:20 +0200 |
parents | 170bdc5c798b |
children | f432d3884b30 |
files | Modules/_decimal/_decimal.c |
diffstat | 1 files changed, 14 insertions(+), 0 deletions(-)[+] [-] Modules/_decimal/_decimal.c 14 |
line wrap: on
line diff
--- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -4340,6 +4340,19 @@ dec_reduce(PyObject *self, PyObject dum return result; } +/ sizeof */ +static PyObject * +dec_sizeof(PyObject *v, PyObject *dummy UNUSED) +{
- res = sizeof(PyDecObject);
- if (mpd_isdynamic_data(MPD(v))) {
res += MPD(v)->alloc * sizeof(mpd_uint_t);[](#l1.15)
- }
- return PyLong_FromSsize_t(res);
+} + /* trunc */ static PyObject * dec_trunc(PyObject *self, PyObject *dummy UNUSED) @@ -4503,6 +4516,7 @@ static PyMethodDef dec_methods [] = { "floor", dec_floor, METH_NOARGS, NULL }, { "trunc", dec_trunc, METH_NOARGS, NULL }, { "complex", dec_complex, METH_NOARGS, NULL },