Skip to content

Optimize parse_parts#92

Merged
p1c2u merged 1 commit intomasterfrom
feature/optimize-parse-parts
Feb 14, 2026
Merged

Optimize parse_parts#92
p1c2u merged 1 commit intomasterfrom
feature/optimize-parse-parts

Conversation

@p1c2u
Copy link
Copy Markdown
Owner

@p1c2u p1c2u commented Feb 14, 2026

This pull request refactors the parse_parts function in pathable/parsers.py to improve performance and readability. The most important changes are grouped below:

Performance and readability improvements:

  • Added fast-path handling for int, str, and bytes types to reduce unnecessary checks and improve efficiency; now, integers are appended directly, strings are checked and split only if needed, and bytes are decoded before processing.
  • Replaced the manual use of parsed.append with a local append variable for cleaner and slightly faster code.
  • Improved error messaging by using f-string formatting for the TypeError.

These changes make the function more efficient and easier to follow, especially when handling common input types.

Benchmarks:

  • All parse and constructor scenarios show performance gains.
  • No regressions detected.
  • Candidate is up to 5.7% faster.

@p1c2u p1c2u force-pushed the feature/optimize-parse-parts branch from 6eb26fc to 63b7f26 Compare February 14, 2026 01:37
@p1c2u p1c2u merged commit b0ef2dc into master Feb 14, 2026
10 checks passed
@p1c2u p1c2u deleted the feature/optimize-parse-parts branch February 14, 2026 01:38
@p1c2u p1c2u restored the feature/optimize-parse-parts branch February 18, 2026 18:13
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.

1 participant