[Python-Dev] Mailbox module - timings and functionality changes (original) (raw)
Guido van Rossum guido at python.org
Wed Jun 30 19:03:49 CEST 2010
- Previous message: [Python-Dev] Mailbox module - timings and functionality changes
- Next message: [Python-Dev] TextIOWrapper.tell()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Jun 30, 2010 at 9:42 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
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.
That's why I proposed not reopening but wrapping.
Of course the contents of the file could still change, but that's a limitation of how the mailbox module works -- it builds a TOC and expects the file not to change.
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.
Well, um, I actually designed it carefully so that bytes offsets would work as text offsets in those cases where they make sense at all.
-- --Guido van Rossum (python.org/~guido)
- Previous message: [Python-Dev] Mailbox module - timings and functionality changes
- Next message: [Python-Dev] TextIOWrapper.tell()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]