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 4 times, most recently from f3656a9 to 454af80 Compare August 5, 2026 20:47
@Person-93
Person-93 force-pushed the no_std_bytes_writer branch from 454af80 to 6e24383 Compare August 7, 2026 00:24
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