Skip to content

No std bytes writer - #6251

Open
Person-93 wants to merge 13 commits into
PyO3:mainfrom
Person-93:no_std_bytes_writer
Open

No std bytes writer#6251
Person-93 wants to merge 13 commits into
PyO3:mainfrom
Person-93:no_std_bytes_writer

Conversation

@Person-93

Copy link
Copy Markdown
Contributor

This is part of the WIP no_std support.

I've made impl of std::io::Write for PyBytesWriter conditional on wip_feature_std. This makes PyBytesWriter completely useless without the std feature, so I've added an additional method write_bytes.

@bschoenmaeckers

Copy link
Copy Markdown
Member

We currently do not expose PyBytesWriter directly. So adding an extra method is not usable right now.

The only usage is a dyn Write ref passed here:

pyo3/src/types/bytes.rs

Lines 160 to 171 in d5daa3d

pub fn new_with_writer<F>(
py: Python<'_>,
reserved_capacity: usize,
write: F,
) -> PyResult<Bound<'_, PyBytes>>
where
F: FnOnce(&mut dyn Write) -> PyResult<()>,
{
let mut writer = PyBytesWriter::with_capacity(py, reserved_capacity)?;
write(&mut writer)?;
writer.try_into()
}

Should we expose PyBytesWriter directly or disable it completely until core has io::Write?

Comment thread src/byteswriter.rs
@Person-93

Copy link
Copy Markdown
Contributor Author

Should we expose PyBytesWriter directly or disable it completely until core has io::Write?

I think it makes sense to expose it directly in that function.

@Person-93
Person-93 force-pushed the no_std_bytes_writer branch from 6647d73 to f37736f Compare July 30, 2026 01:30
@Person-93
Person-93 force-pushed the no_std_bytes_writer branch from ba3470b to 013d76b Compare July 31, 2026 03:34
@Person-93
Person-93 force-pushed the no_std_bytes_writer branch from 013d76b to f3656a9 Compare July 31, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants