Commit 8597d87
Pre-cached iterator, lazy ElementList, O(1) sibling lookup
#1 Iterator pre-caching: ElementIterator pre-builds all (tag_idx,
cached_tag) pairs in a single Document borrow at creation time.
__next__ no longer borrows Document — just clone_ref on pre-cached
values.
#2 Lazy ElementList: Element.xpath() and CompiledXPath.eval() now
return ElementList — holds one Py<Document> + Vec<usize> of tag
indices. Elements created on demand via __getitem__/__iter__.
compiled.eval() for 100K results: 4ms -> 0.07ms (57x faster).
Supports __len__, __getitem__, __iter__, __bool__, __eq__ (with
list comparison).
#7 O(1) sibling lookup: child_positions[i] stored in IndexWithMeta
at parse time. getnext/getprevious use direct index instead of
linear scan over siblings. O(1) instead of O(siblings).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent d79d8be commit 8597d87
File tree
4 files changed
+167
-68
lines changed- python/simdxml
- etree
- src
4 files changed
+167
-68
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
146 | 158 | | |
147 | 159 | | |
148 | 160 | | |
| |||
153 | 165 | | |
154 | 166 | | |
155 | 167 | | |
156 | | - | |
157 | | - | |
| 168 | + | |
| 169 | + | |
158 | 170 | | |
159 | 171 | | |
160 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
0 commit comments