Skip to content
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

simplify speedups implementation #437

Merged
merged 1 commit into from
Apr 19, 2024
Merged

simplify speedups implementation #437

merged 1 commit into from
Apr 19, 2024

Conversation

davidism
Copy link
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.

@davidism davidism added this to the 3.0.0 milestone Apr 19, 2024
@davidism davidism merged commit 0a9df38 into main Apr 19, 2024
11 checks passed
@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