indygreg / indygreg/python-zstandard

The open API is inconsistent

Open
#136 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C
Stars
642
Forks
116
Avg merge
1d 14h
Merged PRs (30d)
5

Description

Iterating over text data works as expected:

In [2]: for line in zstandard.open('123.zst', 'rt'):
   ...:     print(line)
   ...:
123

Iterating over binary data raises an exception:

In [4]: for line in zstandard.open('123.zst', 'rb'):
   ...:     print(line)
   ...:
---------------------------------------------------------------------------
UnsupportedOperation                      Traceback (most recent call last)
<ipython-input-4-42009a852259> in <module>
----> 1 for line in zstandard.open('123.zst', 'rb'):
      2     print(line)

UnsupportedOperation:

I think it makes sense to wrap binary reader/writer in io.BufferedReader/io.BufferedWriter.
Most libraries provide the same interface for text and binary streams.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the zstandard.open entry point and compare how its text and binary readers handle iteration. Check the binary reader and writer behavior against io.BufferedReader and io.BufferedWriter; done means binary streams support iteration without UnsupportedOperation while preserving the existing text behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.