According to the python documentation,
- SEEK_SET or
0
: seek from the start of the stream (the default); offset must either be a number returned byTextIOBase.tell()
, or zero. Any other offset value produces undefined behaviour.- SEEK_CUR or
1
: “seek” to the current position; offset must be zero, which is a nooperation (all other values are unsupported).- SEEK_END or
2
: seek to the end of the stream; offset must be zero (all other values are unsupported).
For SEEK_END
and SEEK_CUR
, why is only 0 offset supported?
Has it simply not been implemented yet/does it need a PEP?
Is this by design? If so, why?
Is there a workaround with acceptable performance (for files with UTF-8, without using undefined behavior)?
All the answers on this question either use undefined behavior or don't handle files with UTF-8.