Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
Open
Description
Bug report
Bug description:
queue.SimpleQueue (C level) uses a list on Python < 3.13[1][2][3][4], a ring buffer on Python >= 3.13[5][6]. However, it does not implement its own__sizeof__() method, and as a result, only the size of thesimplequeueobject structure itself (basicsize) is taken as the size of the object, while the size of the underlying structure is ignored.
>>>fromqueueimportSimpleQueue>>>q=SimpleQueue()>>>q.__sizeof__()72# 56 on Python < 3.13>>>for_inrange(1_000):...q.put(object())...>>>q.__sizeof__()72# 56 on Python < 3.13
Expected (should be, on Python >= 3.13):
>>>fromqueueimportSimpleQueue>>>q=SimpleQueue()>>>q.__sizeof__()136# == 72 + 8*8 == sizeof(simplequeueobject) + sizeof(PyObject *)*INITIAL_RING_BUF_CAPACITY>>>for_inrange(1_000):...q.put(object())...>>>q.__sizeof__()8264# == 72 + 8*1024 == sizeof(simplequeueobject) + sizeof(PyObject *)*pow(2, ceil(log2(1000)))
CPython versions tested on:
3.9, 3.10, 3.11, 3.12, 3.13, 3.14
Operating systems tested on:
Linux