Skip to content

simplify speedups implementation - #437

Merged
davidism merged 1 commit into
mainfrom
simplify-speedups
Apr 19, 2024
Merged

davidism merged 1 commit into
mainfrom
simplify-speedups

Conversation

@davidism

Copy link
Copy Markdown
Member

Only implement the actual string replacement in C. escape, escape_silent, and soft_str are always pure Python. This greatly simplifies the C code, as it no longer needs to do type checks, __html__ check, or string conversion. No longer requires a circular import between Markup and escape. The tests also become simpler, not requiring fixtures for each function. Moving all that to Python only slows down the benchmark by about 20 nanoseconds, which I find acceptable compared to the simpler code.

@carsonburr did this when working on a Rust implementation, as it reduced the amount of non-Rust work done in the Rust code.

co-authored-by: Carson Burr <carsonwburr@gmail.com>
@davidism davidism added this to the 3.0.0 milestone Apr 19, 2024
@davidism
davidism merged commit 0a9df38 into main Apr 19, 2024
@davidism
davidism deleted the simplify-speedups branch April 19, 2024 20:58
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant