python file API

Chris Angelico rosuav at gmail.com
Tue Sep 25 12:12:09 EDT 2012


On Wed, Sep 26, 2012 at 2:07 AM, Dennis Lee Bieber
<wlfraed at ix.netcom.com> wrote:
>         f.pos += delta
>
> would be a "seek.set" and with a naive driver might trigger a rewind to
> the start of the tape followed by a seek to the absolute position,
> whereas the seek from current location would only move the tape by the
> specified amount...

But a smart driver should always optimize the absolute seek to a
relative seek, unless there's a hard difference between them. After
all, the standard "read-ahead" technique is going to do an absolute
seek:

opaque_value = f.tell()
f.read(blah blah blah)
f.seek(opaque_value)

ChrisA



More information about the Python-list mailing list