@@ -5772,6 +5772,20 @@ cpu_set_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
57725772 return (PyObject * )make_new_cpu_set (type , size );
57735773}
57745774
5775+ PyDoc_STRVAR (cpu_set_sizeof_doc ,
5776+ "cpu_set.__sizeof__() -> int\n\n\
5777+ Returns size in memory, in bytes." );
5778+
5779+ static PyObject *
5780+ cpu_set_sizeof (Py_cpu_set * set , PyObject * noargs )
5781+ {
5782+ Py_ssize_t res = 0 ;
5783+
5784+ res = sizeof (Py_cpu_set );
5785+ res += set -> size ;
5786+ return PyLong_FromSsize_t (res );
5787+ }
5788+
57755789static PyObject *
57765790cpu_set_repr (Py_cpu_set * set )
57775791{
@@ -5959,6 +5973,7 @@ static PyMethodDef cpu_set_methods[] = {
59595973 {"isset" , (PyCFunction )cpu_set_isset , METH_VARARGS , cpu_set_isset_doc },
59605974 {"set" , (PyCFunction )cpu_set_set , METH_VARARGS , cpu_set_set_doc },
59615975 {"zero" , (PyCFunction )cpu_set_zero , METH_NOARGS , cpu_set_zero_doc },
5976+ {"__sizeof__" , (PyCFunction )cpu_set_sizeof , METH_NOARGS , cpu_set_sizeof_doc },
59625977 {NULL , NULL } /* sentinel */
59635978};
59645979
0 commit comments