skillfed

iterable-io

Adapt generators and other iterables to a file-like interface

iterable-io v1.0.4 665.6K downloads/30d#5,427 on PyPI3
Copyleft license LGPL-3.0-only Active released

What it is and what it does

iterable-io bridges a common interface mismatch: when one part of your code has a generator or other iterable producing data, but another part expects a file-like object with a `.read()` method. Rather than materializing the entire iterable into a temporary file (which is slow and memory-intensive), this library streams data on demand, pulling from the iterable as `.read()` is called.

The package exports a single function, `open_iterable()`, designed to mimic Python's builtin `open()`. It accepts an iterable, a mode string ('rb', 'rt', etc.), and optional parameters like encoding and buffering, returning a file-like object. This is useful for gluing together incompatible APIs—for example, when a library expects a file handle but your data comes from a generator of bytes or lines.

Use it for:

  • Adapt a generator of bytes to feed into a library that requires a file-like object (e.g., image processing, archive extraction).
  • Stream text data line-by-line from a generator without materializing the full dataset into memory.
  • Convert network streams or database result iterators into file-like interfaces for downstream processing.
  • Avoid temporary file creation when bridging APIs that produce and consume data differently.
  • Read compressed or encoded data from a generator while handling text-mode decoding transparently.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Wraps iterables (generators, lists, etc.) as file-like objects so code expecting `.read()` can consume streaming data without buffering to disk.

Yes. The package solves a real interface-adaptation problem with zero dependencies, low install friction, active maintenance, and no known vulnerabilities. The copyleft license (LGPL-3.0-only) is straightforward for most use cases but requires review if you plan to modify or redistribute the code. Install it when you need to feed an iterable into code expecting a file-like object.

Install

iterable-io on PyPI

pip

pip install iterable-io

uv

uv add iterable-io

poetry

poetry add iterable-io

Installing iterable-io

Before you install

No runtime dependencies and a pure-Python wheel distribution make installation straightforward. The package is actively maintained with a recent release.

License in practice

Licensed under LGPL-3.0-only (copyleft). Any derivative work or modification must be distributed under the same license; static linking or bundling requires careful attention to license compliance.

Quickstart

pip install iterable-io

from iterable_io import open_iterable

gen = (b'chunk' for _ in range(3))
fp = open_iterable(gen, 'rb')
data = fp.read(4096)
fp.close()

Verify before relying

  • Whether the library handles all edge cases for text-mode encoding/decoding (e.g., multi-byte character boundaries across chunk boundaries).
  • Performance characteristics when iterables produce very small chunks or very large chunks.
  • Whether buffering options (if any) are configurable beyond what the docstring documents.

Package facts

License LGPL-3.0-only (copyleft)
Python support supports the current Python release (>=3.5)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 89 days since the last release
Last repo commit
First released
Downloads 665,646/month — #5,427 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: iterable_io-1.0.4-py3-none-any.whl

License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)Operating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

generator to file-like objectiterable file adapterstreaming data interfaceread from generatorfile-like wrapper for iterablesconvert iterable to file objectgenerator file interface
file-like-adapterstreaminginterface-glue

More Software Development packages