GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Replace `std::sync::LazyLock` with `common::lock::LazyLock` by youknowone · Pull Request #7079 · RustPython/RustPython

Conversation

@youknowone

@youknowone youknowone commented Feb 11, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

lock.rs now exports both LazyCell and LazyLock:

  • threading: re-exports from std::sync / core::cell
  • non-threading: LazyCell from core::cell, LazyLock as LazyCell wrapper with Sync (safe without threading)

Summary by CodeRabbit

  • Refactor
    • Updated internal lazy initialization mechanisms to use an optimized local implementation instead of standard library dependencies, improving code consistency across the project.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@youknowone
Replace std::sync::LazyLock with common::lock::LazyLock
e175367
lock.rs now exports both `LazyCell` and `LazyLock`:
  - threading: re-exports from std::sync / core::cell
  - non-threading: `LazyCell` from core::cell, `LazyLock` as
    LazyCell wrapper with Sync (safe without threading)
@youknowone
youknowone marked this pull request as ready for review February 11, 2026 04:22
@coderabbitai

coderabbitai Bot commented Feb 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This change removes the Lazy alias and exposes LazyLock and LazyCell directly in the lock module, adds a LazyLock<T, F> wrapper with a Sync impl and helpers for non-threading builds, and updates many import sites to use rustpython_common::lock::LazyLock (or crate::common::lock::LazyLock).

Changes

Cohort / File(s) Summary
Lock Module Core
crates/common/src/lock.rs
Removed Lazy alias; re-exported LazyLock and LazyCell explicitly. Added public LazyLock<T, F> wrapper around core::cell::LazyCell with unsafe impl Sync, const fn new, force(&Self) -> &T, and Deref impl.
Stdlib imports
crates/stdlib/src/contextvars.rs, crates/stdlib/src/csv.rs, crates/stdlib/src/mmap.rs, crates/stdlib/src/openssl.rs, crates/stdlib/src/ssl/oid.rs, crates/stdlib/src/typing.rs
Replaced imports of std::sync::LazyLock with rustpython_common::lock::LazyLock and updated call sites (e.g., LazyLock::force).
VM builtins imports
crates/vm/src/builtins/...
bytes.rs, dict.rs, genericalias.rs, mappingproxy.rs, memory.rs, range.rs, set.rs, str.rs, template.rs, tuple.rs, union.rs, weakproxy.rs
Replaced std::sync::LazyLock imports with crate::common::lock::LazyLock across builtins.
VM stdlib & types imports
crates/vm/src/stdlib/ctypes/array.rs, crates/vm/src/stdlib/ctypes/pointer.rs, crates/vm/src/stdlib/sre.rs, crates/vm/src/types/structseq.rs
Replaced std::sync::LazyLock with crate::common::lock::LazyLock for static initializers and mapping/sequence helpers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Upgrade threading to 3.13.11; sys.setprofile & impl more threading #6691: Related refactor touching lock abstractions and threading-related lock usage.

Suggested reviewers

  • ShaharNaveh
  • coolreader18
  • fanninpm

Poem

🐰 I nudged the locks to show their name,

No alias hiding, no secret game.
A wrapper snug for single-threaded cheer,
Imports changed — the path now clear.
Hooray, my code hops forward, bright and tame!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately and concisely summarizes the main change: replacing std::sync::LazyLock with common::lock::LazyLock across multiple files, including the new LazyLock implementation in lock.rs.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
crates/stdlib/src/ssl/oid.rs (1)

135-136: Consider importing LazyLock instead of using a fully qualified path.

Other files in this PR import LazyLock with a use statement, but here it's used fully qualified. For consistency:

♻️ Suggested refactor

Add at the top of the file:

use rustpython_common::lock::LazyLock;

Then simplify the declaration:

-static OID_TABLE: rustpython_common::lock::LazyLock<OidTable> =
-    rustpython_common::lock::LazyLock::new(OidTable::build);
+static OID_TABLE: LazyLock<OidTable> = LazyLock::new(OidTable::build);

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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions
Auto-format: cargo fmt --all
35c66f4
@github-actions

github-actions Bot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Code has been automatically formatted

The code in this PR has been formatted using:

  • cargo fmt --all
    Please pull the latest changes before pushing again:
git pull origin lazylock
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone enabled auto-merge (squash) February 11, 2026 07:09
@youknowone
youknowone disabled auto-merge February 11, 2026 07:09
@youknowone
youknowone merged commit ccd3d4f into RustPython:main Feb 11, 2026
13 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone deleted the lazylock branch February 11, 2026 07:09
@coderabbitai coderabbitai Bot mentioned this pull request Mar 4, 2026
Remove Frame mutex and use DataStack bump allocator for LocalsPlus #7333
Merged
youknowone added a commit to youknowone/RustPython that referenced this pull request Mar 22, 2026
@youknowone
Replace std::sync::LazyLock with common::lock::LazyLock (RustPyth…
00cb832
…on#7079)
youknowone added a commit that referenced this pull request Sep 16, 2026
@youknowone
Replace std::sync::LazyLock with common::lock::LazyLock (#7079)
0f8f6ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@youknowone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.