Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Stdlib] Fix time.sleep() truncation for small fractional seconds#6646

Open
BlueDestination wants to merge 2 commits into
modular:mainfrom
BlueDestination:fix-time-sleep
Open

[Stdlib] Fix time.sleep() truncation for small fractional seconds#6646
BlueDestination wants to merge 2 commits into
modular:mainfrom
BlueDestination:fix-time-sleep

Conversation

@BlueDestination

Copy link
Copy Markdown

Linked issue

Fixes #6583

Type of change

  • Bug fix (non-breaking change that fixes an issue)

Motivation

Floating-point truncation causes Int(0.999...)0, so sleep(1e-9) returns immediately.

What changed

Replace Int() with round() in the fractional-seconds-to-nanoseconds conversion.

Testing

All tests pass, including new cases for sub-second sleep durations (e.g., 1ms).

Checklist

  • The linked issue above has been reviewed by a maintainer and is
    agreed-upon, or this is a trivial fix that does not need prior
    approval
  • PR is small and focused — I've split larger changes into a sequence of
    smaller PRs where possible (see
    pull request sizes)
  • I ran ./bazelw run format to format my changes
  • I added or updated tests to cover my changes
  • If AI tools assisted with this contribution, I have included an
    Assisted-by: trailer in my commit message or this PR description (see
    AI Tool Use Policy)
    Assisted-by: AI

@BlueDestination BlueDestination requested a review from a team as a code owner June 6, 2026 09:56
@github-actions github-actions Bot added mojo-stdlib Tag for issues related to standard library waiting-on-review labels Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mojo-stdlib Tag for issues related to standard library waiting-on-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] [stdlib] Function time.sleep() doesn't work for units smaller than seconds anymore

2 participants