Commit d79d8be
Zero-copy parse, eliminate string copies, optimize hot paths
Performance optimizations addressing PyO3 overhead analysis:
1. Zero-copy parse for bytes input (#6): DocumentOwner enum uses
PyBackedBytes to borrow directly from Python bytes object's
internal buffer, avoiding a full memcpy of the XML document.
str input still copies (Python str -> UTF-8 encoding required).
2. Eliminate String intermediaries (#4): All text-returning methods
(xpath_text, xpath_string, .text, .tail, .get, .keys, .items,
itertext, text_content, tostring) now return Py<PyString> built
directly from &str slices. Skips Rust String allocation that
PyO3 would then copy again into Python.
3. interned_tag_fast (#3): Hot paths (child_tags, descendant_tags,
make_element_borrowed, make_elements) now accept &IndexWithMeta
directly, avoiding redundant borrow_dependent() calls in tight
loops.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 30b0702 commit d79d8be
2 files changed
+186
-129
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | | - | |
| 169 | + | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| |||
0 commit comments