Repository navigation
Commit 2f38aba
committed
Keep the input as unconsumed_tail when decompress() reads none of it
With a small max_length, isal_inflate often gives the output from data
it already decoded into its own buffer, and reads no input. The
decompress() method still copied all of its input to a new
unconsumed_tail, so a loop that passes unconsumed_tail back in copied
the whole rest of the compressed stream on most calls. When no input
was read and the input is an exact bytes object that the buffer covers
entirely, unconsumed_tail now keeps a reference to it. Other input,
such as a bytearray, a memoryview or a bytes subclass, is still copied.
Decompressing 4 MiB of Python source compressed at level 2 (1.2 MB) on
Linux, passing unconsumed_tail back in, median of 5 rounds: with
max_length=1024 it goes from 38 to 5.9 ms (6.4x) on Python 3.11 and
from 39 to 5.9 ms (6.7x) on Python 3.14. 8192 is 1.5-1.7x faster and
16384 is 1.2x faster. 65536 and max_length=0 are unchanged.
The only behavior change is identity: after a call that read no
input, unconsumed_tail is the bytes object that was passed in.1 parent 599958d commit 2f38aba
3 files changed
Lines changed: 83 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
12 | 18 | | |
13 | 19 | | |
14 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
983 | 983 | | |
984 | 984 | | |
985 | 985 | | |
986 | | - | |
987 | | - | |
988 | | - | |
989 | | - | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
990 | 1005 | | |
991 | 1006 | | |
992 | 1007 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
261 | 319 | | |
262 | 320 | | |
263 | 321 | | |
| |||
0 commit comments