Skip to content

internal: use std as extern crate#6054

Open
Person-93 wants to merge 2 commits into
PyO3:mainfrom
Person-93:extern_std
Open

internal: use std as extern crate#6054
Person-93 wants to merge 2 commits into
PyO3:mainfrom
Person-93:extern_std

Conversation

@Person-93

@Person-93 Person-93 commented May 18, 2026

Copy link
Copy Markdown
Contributor

This PR is to prepare for no_std support.

  • I've made the main crate no_std and added extern crate std instead.
  • I've also added a new top-level mod platform to hold all the upcoming std replacements. As of now, it just has a prelude which contains
    • Things from the alloc crate people generate use from std's prelude
    • the eprintln macro (we will need to find a replacement for this)
  • I've added import crate::platform::prelude::* to every file that uses things from the standard prelude.
  • The test_utils file could not import the prelude so it had to import directly from the alloc crate.
  • in py_format macro: replace use of ToOwned with Clone

ETA: It looks like a large PR because of the number of files changed, but most of that is just importing the new prelude into the files that need it. There are only four files that have more changes than that.

@Person-93 Person-93 force-pushed the extern_std branch 2 times, most recently from c683aa6 to 43509a5 Compare May 18, 2026 07:30
@Person-93 Person-93 marked this pull request as draft May 18, 2026 07:38
@Person-93 Person-93 force-pushed the extern_std branch 11 times, most recently from ecec57a to 3461bb7 Compare May 18, 2026 09:17
@Person-93 Person-93 marked this pull request as ready for review May 18, 2026 09:42
@Person-93 Person-93 changed the title use std as extern crate internal: use std as extern crate May 24, 2026
@Person-93 Person-93 force-pushed the extern_std branch 2 times, most recently from 4dedc7a to 17559a0 Compare May 26, 2026 20:34
@Person-93 Person-93 force-pushed the extern_std branch 2 times, most recently from deb5f57 to 00a6a54 Compare June 4, 2026 16:22
Comment thread src/conversions/bytes.rs
Comment thread src/platform.rs
@davidhewitt

Copy link
Copy Markdown
Member

Let's merge this to unblock proceeding on this work.

@davidhewitt davidhewitt added this pull request to the merge queue Jun 9, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jun 9, 2026
@davidhewitt

Copy link
Copy Markdown
Member

I can fix the conflicts after #6056 merges.

@codspeed-hq

codspeed-hq Bot commented Jun 15, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 10.74%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 125 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
test_empty_class_init_py 11.7 µs 10.6 µs +10.74%

Tip

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


Comparing Person-93:extern_std (1292803) with main (5c6807d)

Open in CodSpeed

@Person-93

Copy link
Copy Markdown
Contributor Author

@davidhewitt #6056 is not ready to be merged, can we proceed with this one?

@Person-93 Person-93 requested a review from davidhewitt June 18, 2026 17:25
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