Skip to content

Conversation

@alex
Copy link
Member

@alex alex commented Feb 2, 2026

Replace format! + String with PyString::from_fmt + format_args! in repr methods and one PyString::new call, writing directly to a Python string buffer (1 alloc) instead of going through format!() -> String -> PyString (2 allocs + copy). This optimization is only effective on Python 3.14+.

Replace `format!` + String with `PyString::from_fmt` + `format_args!`
in __repr__ methods and one PyString::new call, writing directly to
a Python string buffer (1 alloc) instead of going through
format!() -> String -> PyString (2 allocs + copy). This optimization
is only effective on Python 3.14+.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant