random832 added the comment:

In the analogous C operations, ftell (analogous to .tell) actually causes the 
underlying file descriptor's position (analogous to the raw stream's position) 
to be reset to be at the same value that ftell has returned. Which means, yes, 
that you lose the benefits of buffering if you're so foolish as to call ftell 
after every read. But in this case the sequence "read / tell / truncate" would 
be analogous to "fread(f) / ftell(f) / ftruncate(fileno(f))

Though, the fact that fread operates on the FILE * whereas truncate operates on 
a file descriptor serves as a red flag to C programmers... arguably since this 
is not the case with Python, truncate on a buffered stream should implicitly 
include this same "reset underlying position" operation before actually 
performing the truncate.

----------
nosy: +random832

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26158>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to