[Python-checkins] commit of r41662 - in python/trunk: Misc/NEWS Objects/fileobject.c configure configure.in pyconfig.h.in
Hye-Shik Chang
hyeshik at gmail.com
Wed Dec 14 01:36:26 CET 2005
On 12/14/05, Guido van Rossum <guido at python.org> wrote:
> Isn't it expensive to call isatty() on every tell() call? Is it worth
> it just to make a unit test pass?
>
Indeed. isatty() requires a system call. I think it's somewhat expensive
in case of using tell() for file monitoring or progress bars. But,
it's just for platforms that doesn't return error for ttys. And it's
not clearly defined for ftell(3) in POSIX:
[ESPIPE]
The file descriptor underlying stream is associated with a pipe or FIFO.
[ESPIPE]
The file descriptor underlying stream is associated with a socket.
But, our library reference says that tty.seek() will raise IOError.
So, I thought it should make some consistency.
> Or is there a real bug caused by tell() lying?
I don't think it's harm to keep the original behavior as before this fix.
But file.tell() is quite cheap operation among routines likely enclose
the operation. Hmm. If isatty() for every call still looks too expensive,
we can just fix documentation and unittest. I'm quite neutral for the
problem because tty.tell() is quite non-sense. :)
Hye-Shik
> On 12/13/05, hyeshik.chang <python-checkins at python.org> wrote:
> > Author: hyeshik.chang
> > Date: Tue Dec 13 17:44:02 2005
> > New Revision: 41662
> >
> > Modified:
> > python/trunk/Misc/NEWS
> > python/trunk/Objects/fileobject.c
> > python/trunk/configure
> > python/trunk/configure.in
> > python/trunk/pyconfig.h.in
> > Log:
> > Add a workaround for file.ftell() to raise IOError for ttys.
> > ftell(3) on BSD doesn't set errno even for ttys and returns useless
> > values.
> >
> >
More information about the Python-checkins
mailing list