On 6/21/07, Daniel Stutzbach <[EMAIL PROTECTED]> wrote:
> On 6/21/07, Guido van Rossum <[EMAIL PROTECTED]> 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?

Yes, so the API for seek() and tell() can be the same for binary and
text files. It also makes it easier to persist cookies.

> 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.

I actually like the "open kimono" approach where users can work around
the system if they really need to.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to