-
Notifications
You must be signed in to change notification settings - Fork 922
Add PyBytes::new_with_writer
#5517
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
base: main
Are you sure you want to change the base?
Conversation
a016633 to
1593104
Compare
| } | ||
|
|
||
| if !(*writer).obj.is_null() { | ||
| if crate::_PyBytes_Resize(&mut (*writer).obj, size) > 0 { |
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.
It’s a shame that _PyBytes_Resize is not available on the limited api. 😢
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.
I wonder if it's viable to just use a Vec<u8> until calling .finish(). This might defeat the point of the API for users, but at the same time it would let us support it cleanly on all versions 🤔
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.
I wonder if it's viable to just use a
Vec<u8>until calling.finish(). This might defeat the point of the API for users, but at the same time it would let us support it cleanly on all versions 🤔
I was hesitant to fallback to Vec for the same reason. But it seems fine to do it like this to make it work.
de94a5a to
89a3e09
Compare
|
How can I make pyo3-ffi-check happy? It is complaining that |
244df75 to
5318908
Compare
85b55d9 to
7bfa6f4
Compare
7bfa6f4 to
c367d60
Compare
c367d60 to
cb5a20d
Compare
7f64f95 to
dd65502
Compare
Adds a new constructor on
PyBytesthat allows creating a python bytes object using astd::io::Writewriter. I've exposed the writer as&mut dyn Writedyn object so we do not have to expose the internal writer implementation. We can change this to&mut PyBytesWriterat a later stage if that seems necessary.closes #4003