diff options
author | Jesus Cea <jcea@jcea.es> | 2012-08-03 12:18:11 (GMT) |
---|---|---|
committer | Jesus Cea <jcea@jcea.es> | 2012-08-03 12:18:11 (GMT) |
commit | 5323173dee1f20fc53c2df4707ec6d266534b748 (patch) | |
tree | bae19c56eed10e2d870c472a8cb68577455c0291 /Modules/posixmodule.c | |
parent | 077ef45a749ccaa0b7d426c83ca7f8df3523a0e3 (diff) | |
download | cpython-5323173dee1f20fc53c2df4707ec6d266534b748.zip cpython-5323173dee1f20fc53c2df4707ec6d266534b748.tar.gz cpython-5323173dee1f20fc53c2df4707ec6d266534b748.tar.bz2 |
Closes #15514: Correct __sizeof__ support for cpu_set
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index bbf9baf..ce10d1b 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5772,6 +5772,20 @@ cpu_set_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return (PyObject *)make_new_cpu_set(type, size); } +PyDoc_STRVAR(cpu_set_sizeof_doc, +"cpu_set.__sizeof__() -> int\n\n\ +Returns size in memory, in bytes."); + +static PyObject * +cpu_set_sizeof(Py_cpu_set *set, PyObject *noargs) +{ + Py_ssize_t res = 0; + + res = sizeof(Py_cpu_set); + res += set->size; + return PyLong_FromSsize_t(res); +} + static PyObject * cpu_set_repr(Py_cpu_set *set) { @@ -5959,6 +5973,7 @@ static PyMethodDef cpu_set_methods[] = { {"isset", (PyCFunction)cpu_set_isset, METH_VARARGS, cpu_set_isset_doc}, {"set", (PyCFunction)cpu_set_set, METH_VARARGS, cpu_set_set_doc}, {"zero", (PyCFunction)cpu_set_zero, METH_NOARGS, cpu_set_zero_doc}, + {"__sizeof__", (PyCFunction)cpu_set_sizeof, METH_NOARGS, cpu_set_sizeof_doc}, {NULL, NULL} /* sentinel */ }; |