diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_elementtree.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index cb84048..6415797 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -842,6 +842,19 @@ element_deepcopy(ElementObject* self, PyObject* args) return NULL; } +static PyObject* +element_sizeof(PyObject* _self, PyObject* args) +{ + ElementObject *self = (ElementObject*)_self; + Py_ssize_t result = sizeof(ElementObject); + if (self->extra) { + result += sizeof(ElementObjectExtra); + if (self->extra->children != self->extra->_children) + result += sizeof(PyObject*) * self->extra->allocated; + } + return PyLong_FromSsize_t(result); +} + LOCAL(int) checkpath(PyObject* tag) { @@ -1609,6 +1622,7 @@ static PyMethodDef element_methods[] = { {"__copy__", (PyCFunction) element_copy, METH_VARARGS}, {"__deepcopy__", (PyCFunction) element_deepcopy, METH_VARARGS}, + {"__sizeof__", element_sizeof, METH_NOARGS}, {NULL, NULL} }; |