[Python-3000] On PEP 3116: new I/O base classes

Daniel Stutzbach daniel at stutzbachenterprises.com
Fri Jun 22 05:40:38 CEST 2007


On 6/21/07, Guido van Rossum <guido at python.org> wrote:
> In my mind, seek() and tell() should work like getpos() and setpos()
> in modern C stdio -- tell() returns a "cookie" whose only use is that
> you can later pass it to seek() and it will reset the position in the
> sequence of code units to where it was when tell() was called. For
> many encodings, in practice, seek() and tell() can just use byte
> positions since the boundaries between code points always fall on byte
> boundaries (but not the other way around). For other encodings, the
> implementation currently in io.py encodes the incremental codec state
> in the (very) high bits of the cookie (this is convenient since we
> have arbitrary precision integers).

If the cookie is meant to be opaque to the caller, is there a reason
that the cookie must be an integer?

Specifying the return type as opaque might also reduce the temptation
to do perform arithmetic on them, which will work for some codecs
(ASCII), but break later in odd ways for others.

-- 
Daniel Stutzbach, Ph.D.             President, Stutzbach Enterprises LLC


More information about the Python-3000 mailing list