mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Issue #14055: Add __sizeof__ support to _elementtree.
This commit is contained in:
parent
1e5d0ff8a0
commit
bce166681c
3 changed files with 53 additions and 2 deletions
|
|
@ -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}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue