Commit d12e757
Feature: accept any buffer instance when processing file data (#148)
- 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 "data 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.
Closes #46
Co-authored-by: Alyssa Coghlan <[email protected]>1 parent 3a81ccb commit d12e757
1 file changed
+19
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
529 | 531 | | |
530 | 532 | | |
531 | 533 | | |
532 | | - | |
| 534 | + | |
533 | 535 | | |
534 | 536 | | |
535 | 537 | | |
536 | 538 | | |
537 | 539 | | |
538 | | - | |
| 540 | + | |
539 | 541 | | |
540 | | - | |
541 | | - | |
542 | | - | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
543 | 552 | | |
544 | 553 | | |
545 | 554 | | |
| |||
550 | 559 | | |
551 | 560 | | |
552 | 561 | | |
| 562 | + | |
553 | 563 | | |
554 | 564 | | |
555 | 565 | | |
556 | | - | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
557 | 569 | | |
558 | 570 | | |
559 | 571 | | |
| |||
573 | 585 | | |
574 | 586 | | |
575 | 587 | | |
576 | | - | |
| 588 | + | |
577 | 589 | | |
578 | 590 | | |
579 | 591 | | |
| |||
0 commit comments