[issue1351] Add getsize() to io instances

Christian Heimes report at bugs.python.org
Thu Nov 8 15:59:56 CET 2007


Christian Heimes added the comment:

> (a) the SizeInfo class is overkill.  getsize() should just return an int.

But I like overkill :)

> (b) getsize() should check self.seekable() first and raise the
appropriate error if the file isn't seekable.

That's easy to implement

> (c) os.fstat() is much less likely to work than the tell-seek-tell-seek
sequence, so why not use that everywhere?

fstat doesn't have concurrency problems in multi threaded apps. I
haven't profiled it but I would guess that fstat is also faster than
tell seek.

> (d) people will expect to use this on text files, but of course the
outcome will be in bytes, hence useless.

I could rename the method to getfssize, getbytesize, getsizeb ... to
make clear that it doesn't return the amount of chars but the amount of
used bytes.

----------
keywords: +patch, py3k
priority:  -> low

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1351>
__________________________________


More information about the Python-bugs-list mailing list