-
Notifications
You must be signed in to change notification settings - Fork 0
Ruff #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ruff #2
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,114 @@ | ||||||
| """Parallel highlighting benchmark for free-threading visibility. | ||||||
|
|
||||||
| Run with: | ||||||
| python benchmarks/benchmark_parallel.py | ||||||
| python -m benchmarks.benchmark_parallel | ||||||
|
|
||||||
| Demonstrates thread scaling when highlighting many code blocks in parallel | ||||||
| under Python 3.14t free-threading. Uses highlight_many() for parallel path | ||||||
| and sequential highlight() loop for baseline. Stdlib only. | ||||||
|
||||||
| and sequential highlight() loop for baseline. Stdlib only. | |
| and sequential highlight() loop for baseline. No third-party dependencies. |
Copilot
AI
Mar 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_load_sample_code()’s docstring says it “load[s] sample_code”, but the function only prepends the repo root to sys.path. Consider either importing benchmarks.sample_code inside the function (so it actually “loads” it) or updating the docstring to describe what it really does.
| """Add repo root to path and load sample_code (for script execution).""" | |
| """Ensure repo root is on sys.path so benchmarks.sample_code can be imported.""" |
Copilot
AI
Mar 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This benchmark duplicates free-threading/GIL detection via sys._is_gil_enabled. Since the project already has rosettes._parallel.is_free_threaded() (with fallback behavior), consider reusing that helper to keep detection logic consistent and avoid depending on a CPython private attribute in two places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README claim of “zero contention” is stronger than what the implementation guarantees. Even if lexer state is local/immutable, the library still uses shared machinery (e.g., registry caching via
functools.cache,ThreadPoolExecutorinternals), so there can be contention outside the lexer state. Consider rephrasing to something precise like “no shared mutable lexer state” / “safe to call concurrently” rather than “zero contention.”