Skip to content

No alloc Unicode version - #9820

Merged
youknowone merged 1 commit into
RustPython:mainfrom
joshuamegnauth54:comp-time-ucd-version
Nov 14, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
joshuamegnauth54:comp-time-ucd-version

Conversation

@joshuamegnauth54

@joshuamegnauth54 joshuamegnauth54 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Simple patch that moves the NameAliases version parser to build.rs. This avoids embedding the text file just to parse the file line each time unicode_version() is called.

I also fixed version_owner to allocate less by not constructing a temporary String to turn into a CString.

  • Closes #xxxx

One of checkbox below must be checked.

  • I did not use AI to write the code of this patch.
  • This PR follows our AI policy

Summary by CodeRabbit

  • Bug Fixes
    • Unicode version reporting now reflects the bundled data for modern views and reports version 3.2.0 for legacy views. Version information is available consistently across the supported data views.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-12T19:02:51.901214Z
We couldn’t complete this review. Comment @codex review to try again.
f6631da PR opened
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The build script now extracts the modern Unicode version at compile time. The Unicode library exposes modern and legacy version constants, and the standard library uses them for its Unicode version values.

Changes: Unicode version source and consumers

Layer / File(s) Summary
Build-time version extraction
crates/unicode/build.rs
The build script validates the version from the first line of NameAliases.txt and emits it as UNICODE_VERSION. It runs this parser alongside the block parser in small_parsers.
Unicode version constants and accessors
crates/unicode/src/data.rs, crates/unicode/src/lib.rs
The Unicode library defines and re-exports UNICODE_VERSION and UNICODE_VERSION_LEGACY. Ucd::unidata_version() returns the applicable constant. The version test checks the modern constant, and the former unicode_version() function is removed.
Standard-library version values
crates/stdlib/src/unicodedata.rs
Ucd::new initializes its version from the modern or legacy constant. The module-level unidata_version returns UNICODE_VERSION. CString construction panics if the selected value contains an internal NUL.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: youknowone, youknowdot

Merge Risk: Minimal · up to 4ebb3

This change computes the Unicode version at build time instead of parsing a file on every call. No actionable merge-blocking risk was identified. The reported CI failure should be confirmed to come from the toolchain version rather than from this change.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "No alloc Unicode version" names a real part of the change: the Unicode version lookup is moved to build-time constants (UNICODE_VERSION and UNICODE_VERSION_LEGACY) and the runtime unicode_v…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "No alloc Unicode version" names a real part of the change: the Unicode version lookup is moved to build-time constants (UNICODE_VERSION and UNICODE_VERSION_LEGACY) and the runtime unicode_version() function that parsed NameAliases.txt and allocated a String is removed. The title is terse and omits the build.rs move and the legacy version constant, but it still points at the primary intent stated in the PR objectives, which is avoiding runtime parsing and allocation when computing the version. It is not off-topic and not vague.

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 419664d and 4ebb3c5.

Files selected for processing: 2

  • crates/unicode/build.rs
  • crates/unicode/src/data.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@joshuamegnauth54

Copy link
Copy Markdown
Contributor Author

I think CI is failing due to Rust version 1.100. Everything passes locally on 1.99.

Simple patch that moves the NameAliases version parser to build.rs. This
avoids embedding the text file just to parse the file line each time
unicode_version() is called.

I also fixed version_owner to allocate less by not constructing a
temporary String to turn into a CString.
@codspeed

codspeed Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing joshuamegnauth54:comp-time-ucd-version (4ebb3c5) with main (9a82f61)

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 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@youknowone
youknowone merged commit 9fa2b8e into RustPython:main Nov 14, 2026
21 checks passed
@joshuamegnauth54
joshuamegnauth54 deleted the comp-time-ucd-version branch November 16, 2026 19:44
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