indygreg / indygreg/python-zstandard

Return True from ZstdDecompressionReader.seekable

Open
#222 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

There are several issues on this tracker discussing python-zstandard's approach to `.seek`, summarised by this comment: https://github.com/indygreg/python-zstandard/issues/216#issuecomment-2005651108

But it sounds like python-zstandard is still happy with forward seeks. If so, we should `return True` from `seekable`, so that e.g. we can forward seek through `io.BufferedReader`: https://github.com/python/cpython/blob/dd0a1f9da283bd784e2c88efec0a45cef978516a/Modules/_io/bufferedio.c#L1227

Here's a small repro:
```
import zstandard
fn = "whatever.zst"
unbuffered = zstandard.open(fn)
unbuffered.seek(10)
unbuffered.read(10) # works fine

buffered = io.BufferedReader(zstandard.open(fn))
buffered.seek(10) # fails
# UnsupportedOperation: File or stream is not seekable.
```

It's useful to wrap with BufferedReader to get functionality like `readline` (I noticed you recommended doing this here as well :-) https://github.com/indygreg/python-zstandard/issues/13#issuecomment-466797822 )

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 ZstdDecompressionReader.seekable and reproduce the difference between direct seeking and seeking through io.BufferedReader with the example in the issue. Check the related issue discussion for the intended forward-seek behavior; done means BufferedReader.seek(10) succeeds and the subsequent read works.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.