Commit 42bda74
refactor: optimize file handling to avoid redundant buffer conversions
- Change _get_file_details() to return Buffer instead of bytes
- Add special handling for memoryview inputs to avoid unnecessary conversion
- Support all buffer protocol objects (bytes, bytearray, memoryview, array.array, etc.)
- Update type annotations throughout to use Buffer type from typing_extensions
- Improve error messages to mention "buffer" instead of just "bytes"
This change reduces memory overhead when working with buffer protocol objects
by preserving memoryview objects instead of converting them to bytes unnecessarily.1 parent f0b093e commit 42bda74
2 files changed
+4
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
558 | | - | |
| 558 | + | |
559 | 559 | | |
560 | 560 | | |
561 | | - | |
| 561 | + | |
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
0 commit comments