Skip to content

refactor: share PyTime conversions with time.sleep - #9362

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:cpython315-pytime-production-reuse
Oct 26, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:cpython315-pytime-production-reuse

Conversation

@youknowdot

@youknowdot youknowdot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Share the existing CPython-style PyTime conversion implementation with production time.sleep instead of maintaining the same conversion twice.

  • Move the landed numerical helper from _testinternalcapi/pytime.rs to time/pytime.rs and reuse from_seconds_object(..., Round::Up) in sleep.
  • Preserve every conversion body, the existing _testinternalcapi argument-binding and diagnostics, and the sleep audit, negative-duration rejection, and platform backends.
  • No dependency, Lib, test, thread-lifecycle, or public Python API changes. This is a behavior-preserving extraction from Integrate remaining Python 3.15 final runtime and libraries #8954, not a new numeric feature.

Validation

  • Locked/offline VM library check: passed.
  • Locked/offline strict VM library Clippy: passed.
  • Fresh default CLI build: passed.
  • Existing test.test_time.TimeTestCase.test_sleep_exceptions: passed on a fresh, independently sealed binary. This selects only conversion-error and negative-duration cases; no positive sleeps, explicit signal delivery, thread/process creation, or full-module run. Normal interpreter/import initialization is unchanged.

Local validation is based on ef6e2dbaee626e7ea2f24900867fcd4f5aa6ab56. The patch merges cleanly with main b7bebe638c8a44dc2a7ec90cfd6c17912ec88876; its newer memmap2/object dependency graph has not been rebuilt locally and is left to current-merge CI. The full workspace/C-API suites were not run.

Source comparison uses CPython 3.15's object conversion and timeout-rounding contract. The full numerical fixture classes are unavailable on this main baseline; no skipped class is counted as coverage.

AI assistance: OpenAI Codex assisted with the extraction, source review, and validation preparation.

Move the existing conversion helper into the production time module and reuse it from sleep, preserving conversion bodies and internal C-API argument binding.

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

coderabbitai Bot commented Oct 25, 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.

@codspeed

codspeed Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 11.03%

⚡ 1 improved benchmark
✅ 61 untouched benchmarks
⏩ 4 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ rustpython[comprehension_list.py] 889.1 µs 800.8 µs +11.03%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing youknowdot:cpython315-pytime-production-reuse (f811005) with main (b7bebe6)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@youknowone
youknowone marked this pull request as ready for review October 26, 2026 01:07
@youknowone
youknowone merged commit 1170a33 into RustPython:main Oct 26, 2026
31 checks passed
@chatgpt-codex-connector

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 🔄 Running since 2026-10-26T01:07:49.690385Z f811005 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.

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.

2 participants