self.assertIs(b, l)
self.assertEqual(l.count(), 3)
+ @requires_sched_affinity
+ @support.cpython_only
+ def test_cpu_set_sizeof(self):
+ self.assertGreater(sys.getsizeof(posix.cpu_set(1000)),
+ sys.getsizeof(posix.cpu_set(1)))
+
def test_rtld_constants(self):
# check presence of major RTLD_* constants
posix.RTLD_LAZY
- Issue #15487: Add a __sizeof__ implementation for buffered I/O objects.
Patch by Serhiy Storchaka.
+- Issue #15514: Correct __sizeof__ support for cpu_set.
+ Patch by Serhiy Storchaka.
+
- Issue #15187: Bugfix: remove temporary directories test_shutil was leaving
behind.
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)
{
{"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 */
};