PyByteBuffer is a Python library for manipulating byte buffers, drawing inspiration from Java's `java.nio.ByteBuffer`. It provides methods for writing and reading various data types (integers, strings, arrays, bytes) into a buffer with control over aspects like endianness and position. The current stable version is 1.0.5, released in late 2020, and it appears to be in a maintenance status, stable for its intended functionality.
pip install PyByteBufferVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a ByteBuffer, write different data types into it, reset its position, and then read the data back. It also highlights the behavior of `get()` versus `read()` methods concerning position advancement.
Explicitly call `buffer.position(new_pos)` or use `buffer.read(...)` methods which advance the position automatically.
Always explicitly specify endianness (e.g., `bb.write(value, 'int', 4, endian='big')`) if data exchange requires it, or if consistency across different systems is important.
Profile code that heavily uses `int` to `bytes` or `bytes` to `int` conversions. Consider batching operations or alternative approaches if performance becomes an issue.
Ensure the library is installed using `pip install PyByteBuffer` and import it using `from PyByteBuffer import ByteBuffer`.
Before reading or writing, check `buffer.remaining()` to ensure sufficient bytes are available, or use `buffer.capacity()` and `buffer.limit()` to understand the buffer's boundaries. Adjust `buffer.position()` as needed.
Verify the correct type strings accepted by the `write()` and `read()` methods, such as 'int', 'str', 'bytes', 'array', etc., as specified in the library's documentation.
No dependency data recorded yet.