Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

queue.SimpleQueue.__sizeof__() ignores the underlying data structure #140025

Open
Labels
extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error
@x42005e1f

Description

@x42005e1f

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

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp