Registry / http-networking / iterable-io

iterable-io

JSON →
library1.0.4pypypi✓ verified 83d ago

iterable-io is a lightweight Python library (current version 1.0.1) that provides an `IterableIO` class to adapt any byte-iterable (like generators, lists, or custom iterators) into a file-like object conforming to the `io.RawIOBase` interface. This allows iterables to be used in contexts expecting file-like objects, such as `zipfile.ZipFile`, `tarfile.TarFile`, or HTTP request bodies. The library is stable with a slow, focused release cadence.

pip install iterable-io
INSTALL
IMPORT
SIG · ITERABLE-IO
I
iterable-io
http-networkingpythonv1.0.4
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RawIterableReader
from iterableio import RawIterableReader
from iterable_io import IterableIO
io
from iterableio import io
open_iterable
from iterableio import open_iterable

Demonstrates creating an `IterableIO` from a byte generator and using it directly or wrapping it with `io.TextIOWrapper` for string-based operations.

from iterable_io import IterableIO import io # Example 1: Adapting a generator of bytes def byte_generator(): yield b"Hello" yield b" " yield b"World!" # Create an IterableIO object from the generator file_like_object = IterableIO(byte_generator()) # Use it like a file print(f"Read 6 bytes: {file_like_object.read(6).decode()}") # Output: Hello print(f"Read remaining: {file_like_object.read().decode()}") # Output: World! # Example 2: Adapting string data using io.TextIOWrapper string_data = ["line1\n", "line2\n", "last line"] # The IterableIO expects bytes, so encode the strings byte_stream = IterableIO(s.encode('utf-8') for s in string_data) # Wrap with TextIOWrapper for text operations text_stream = io.TextIOWrapper(byte_stream, encoding='utf-8') print(f"First line: {text_stream.readline().strip()}") # Output: line1 print(f"Second line: {text_stream.readline().strip()}") # Output: line2 text_stream.close()
Debug
Known issues
gotcha`IterableIO` expects an iterable of bytes. If you pass an iterable of strings, you must encode them yourself (e.g., `(s.encode('utf-8') for s in string_iterable)`) or wrap the `IterableIO` instance with `io.TextIOWrapper`.
fix
Ensure the underlying iterable yields `bytes` objects, or use `io.TextIOWrapper(IterableIO(byte_iterable), encoding='utf-8')` for text handling.
affects: >=1.0.0
gotcha`IterableIO` instances are read-only by default. Attempts to call `write()` or related methods will raise an `io.UnsupportedOperation`.
fix
This library is designed for reading from iterables. If write functionality is needed, a different approach or library should be used, or a custom class inheriting from `io.RawIOBase` that implements writable methods.
affects: >=1.0.0
gotchaThe `read(size)` method may return less than `size` bytes if the underlying iterable yields a smaller chunk or is exhausted. It returns an empty bytes object `b''` only when the iterable is fully consumed.
fix
Always check the return value of `read()` for `b''` to detect end-of-file, rather than assuming it will return exactly `size` bytes or `None`.
affects: >=1.0.0
Upgrade
Version history
1.0.4latest on PyPI · released May 17, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
iterable-io — pip install iterable-io · libregistry