@@ -238,18 +238,28 @@ simplequeue_traverse(PyObject *op, visitproc visit, void *arg)
238238 Py_VISIT (Py_TYPE (self ));
239239 return 0 ;
240240}
241- static PyObject *
242- simplequeue_sizeof (PyObject * op , PyObject * Py_UNUSED (ignored ))
241+
242+ /*[clinic input]
243+ @critical_section
244+ _queue.SimpleQueue.__sizeof__ -> Py_ssize_t
245+
246+ Returns size in memory, in bytes.
247+ [clinic start generated code]*/
248+
249+ static Py_ssize_t
250+ _queue_SimpleQueue___sizeof___impl (simplequeueobject * self )
243251{
244- simplequeueobject * self = simplequeueobject_CAST (op );
245252 Py_ssize_t size = Py_TYPE (self )-> tp_basicsize ;
253+ PyObject * * items = self -> buf .items ;
254+ Py_ssize_t items_cap = self -> buf .items_cap ;
246255
247- if (self -> buf . items != NULL ) {
248- size += ( Py_ssize_t ) self -> buf . items_cap * (Py_ssize_t )sizeof (PyObject * );
256+ if (items != NULL ) {
257+ size += items_cap * (Py_ssize_t )sizeof (void * );
249258 }
250259
251- return PyLong_FromSsize_t ( size ) ;
260+ return size ;
252261}
262+ /*[clinic end generated code: output=58ce4e3bbc078fd4 input=a3a7f05c9616598f]*/
253263
254264/*[clinic input]
255265@classmethod
@@ -546,7 +556,7 @@ static PyMethodDef simplequeue_methods[] = {
546556 _QUEUE_SIMPLEQUEUE_PUT_METHODDEF
547557 _QUEUE_SIMPLEQUEUE_PUT_NOWAIT_METHODDEF
548558 _QUEUE_SIMPLEQUEUE_QSIZE_METHODDEF
549- { "__sizeof__" , ( PyCFunction ) simplequeue_sizeof , METH_NOARGS , NULL },
559+ _QUEUE_SIMPLEQUEUE___SIZEOF___METHODDEF
550560 {"__class_getitem__" , Py_GenericAlias ,
551561 METH_O |METH_CLASS , PyDoc_STR ("See PEP 585" )},
552562 {NULL , NULL } /* sentinel */
0 commit comments