[Python-Dev] Mailbox module - timings and functionality changes

Antoine Pitrou solipsis at pitrou.net
Wed Jun 30 18:42:58 CEST 2010


On Tue, 29 Jun 2010 20:05:29 -0400
"R. David Murray" <rdmurray at bitdance.com> wrote:
> 
> I would imagine Guido is talking about an io.TextIOWrapper...in other
> words, take the binary file you've just finished grabbing info
> from, and reread it as a text file in order to grab the actual
> message content.

This sounds a bit suboptimal to me (and introduces race conditions if
e.g. the file is replaced with another one before you reopen it). You
could instead decode the binary data by yourself, especially if you
have already stored that data somewhere.

Also, please note that values used by seek() and tell() on
text I/O are "opaque cookies". While they can happen to match the
raw binary file position, it is a mere coincidence (or an
implementation detail, at your will). Therefore, reusing tell() values
of a binary file to seek() a TextIOWrapper accessing the same file
is wrong.




More information about the Python-Dev mailing list