Skip to content

Account for SimpleQueue buffer capacity in sizeof - #9415

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:upgrade/queue-sizeof-20261028
Oct 28, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:upgrade/queue-sizeof-20261028

Conversation

@youknowdot

@youknowdot youknowdot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Account for SimpleQueue's allocated ring-buffer storage in __sizeof__, using the existing Rust container convention: Rust payload size plus buffer capacity times element-reference size.
  • Sync test_queue from canonical CPython 3.15.0 (d220409a13b77de7a6c30abe16ea90db01528edc) using scripts/update_lib migrate, then its explicit JSON patch machinery.
  • Add one new, narrowly scoped expectedFailure on CSimpleQueueTest.test_simplequeue_sizeof: this assertion encodes CPython's simplequeueobject layout (?nnPnnP), which differs from Rust's queue and optional semaphore layout. The test is otherwise canonical. No global skips, helper changes, or fabricated CPython memory size.

Source comparison

CPython Modules/_queuemodule.c counts its object size plus ring capacity; Doc/library/sys.rst excludes objects merely referred to. Rust's PyList.__sizeof__ uses payload size plus allocation capacity, while sys.getsizeof adds the Rust object header. The new queue implementation follows those Rust conventions and takes its existing buffer lock. It performs no allocation, traversal, or queue-algorithm change.

Validation

  • cargo fmt --all -- --check: passed.
  • Updater unit suite: 221 passed (PYTHONPATH=scripts python3 -m unittest discover -s scripts/update_lib/tests).
  • Canonical source comparison: exactly the single documented decorator differs.
  • Focused stdlib compilation (host_env,threading) and stdlib+host_env Clippy: passed.
  • Normal repository hooks: passed.
  • RustPython runtime tests and full workspace/C API suites: not run locally; no built interpreter is available. No runtime success claimed.

For exact head cb78d62429f7311ac9dd0a0d4f75bcc60d6dca22, correctness CI passed (14 passed jobs, 2 expected skips), and Lib Dependencies Check passed. Local runtime limitations above remain unchanged. This remains a draft for maintainer review.

AI-assisted implementation and source review.

Follow Rust container memory accounting and migrate the canonical Python 3.15 queue tests with scripts/update_lib. Mark only the CPython-specific object-layout size assertion as expectedFailure through explicit updater metadata.

Assisted-by: OpenAI Codex: model version unavailable
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

[x] lib: cpython/Lib/queue.py
[x] test: cpython/Lib/test/test_queue.py (TODO: 1)

dependencies:

  • queue

dependent tests: (19 tests)

  • queue: test_android test_asyncio test_concurrent_futures test_dummy_thread test_genericalias test_logging test_sched test_socket
    • concurrent.futures.process: test_compileall
    • logging.handlers: test_pkgutil
    • multiprocessing: test_asyncio test_concurrent_futures test_fcntl test_importlib test_memoryview test_multiprocessing_forkserver test_multiprocessing_main_handling test_profiling test_re

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

@youknowone
youknowone marked this pull request as ready for review October 28, 2026 08:33
@youknowone
youknowone merged commit b9bb860 into RustPython:main Oct 28, 2026
21 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-28T08:34:45.829727Z
We couldn’t complete this review. Comment @codex review to try again.
cb78d62 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

youknowdot pushed a commit to youknowdot/RustPython that referenced this pull request Oct 28, 2026
Integrate main 07b1cdb after the earlier unpublished main merge, carrying
landed RustPython#9415 through RustPython#9420. Preserve queue accounting, fcntl/ioctl buffers,
resource limits, complex memoryview and array formats, and Windows registry
compatibility with their canonical tests.

The automatic Cargo.lock merge adds the stdlib half dependency while
preserving the existing Ruff parser vendor override. Other incoming and
residual paths remain byte-for-byte with their respective parents.

The updater suite passed 226 tests; affected-file hooks passed. No fresh
local Rust build or interpreter runtime was run. Local cspell remains
deferred to exact-head CI under the user's instruction.

AI assistance covered source integration, review and validation.
Assisted-by: dot: model version not exposed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants