Commit 6860dc5
committed
Rework and optimize
Make `_Extra` a normal class rather than a subclass of `bytes`,
avoiding the performance penalty of copying the passed bytes upon each
instantiation.
Introduce `.iter()` in place of `.strip()` to yield each subfield info
as a tuple. This provides better semantics and is more performant than
subclassing `bytes`. The method name change also enables feature
detection for these behavior changes.
Stop using memoryview internally because each slice creates an overhead
of around 184 bytes, making it inefficient for small bytes operations
(each extra field is usually only several to tens of bytes).
Remove `.read_one()` since it is now unused and obsolete._Extra
1 parent 3a2147e commit 6860dc5
1 file changed
Lines changed: 30 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
| 198 | + | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | 201 | | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
217 | 207 | | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
225 | 220 | | |
226 | 221 | | |
227 | 222 | | |
228 | 223 | | |
229 | 224 | | |
230 | 225 | | |
231 | | - | |
232 | | - | |
| 226 | + | |
| 227 | + | |
233 | 228 | | |
234 | 229 | | |
235 | 230 | | |
236 | 231 | | |
237 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
238 | 237 | | |
239 | | - | |
240 | | - | |
241 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
242 | 241 | | |
243 | 242 | | |
244 | | - | |
| 243 | + | |
| 244 | + | |
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| |||
600 | 600 | | |
601 | 601 | | |
602 | 602 | | |
603 | | - | |
604 | | - | |
| 603 | + | |
605 | 604 | | |
606 | 605 | | |
607 | 606 | | |
| |||
0 commit comments