-
Notifications
You must be signed in to change notification settings - Fork 107
Feature: accept any buffer instance when processing file data #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 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.
- Fix trailing comma in Buffer import - Remove redundant type annotation to fix mypy error - Add groups = dev to typecheck tox environment - Remove trailing whitespace
|
All contributors have signed the CLA ✍️ ✅ |
|
@ncoghlan I cannot find the location of which I confirm the CLA. I think the site maybe broken ? |
|
|
I have read the CLA Document and I hereby sign the CLA |
thanks bro |
ncoghlan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice improvement, thanks!
I'd like to arrange the updated checks in _get_file_details a bit differently, but the details are beyond what GitHub will tolerate as a multi-line suggestion, so I'll change those locally and push them up to the branch.
Co-authored-by: Alyssa Coghlan <[email protected]>
Co-authored-by: Alyssa Coghlan <[email protected]>
Sounds good to me! |
|
@ncoghlan I don't think I can merge it requires me to have write permissions I believe, it just shows close with comment on my side. |
Aye, there was a gap between approval and merging as I was also running the full test suite against my local LM Studio instance (the automated CI's coverage is unfortunately still limited for now). Local tests were all green, though, so thanks for the enhancement! |
|
Follow up PR to add test cases for the newly accepted file data input types: #152 |
|
This will be released as part of lmstudio-python 1.5.0. |


refactor: optimize file handling to avoid redundant buffer conversions
This change reduces memory overhead when working with buffer protocol objects
by preserving memoryview objects instead of converting them to bytes unnecessarily.
Closes #46