[Python-Dev] proposed struct module format code addition

Andrew Durdin adurdin at gmail.com
Mon Oct 4 13:21:48 CEST 2004

On Mon, 04 Oct 2004 08:16:33 +0200, Martin v. Löwis <martin at v.loewis.de> wrote:
> Andrew Durdin wrote:
> > I have an application where I have to read and write a series of
> > 24-bit integers in a binary file. The g and G codes would make this
> > more convenient, as well as making all the reading and writing code
> > more consistent (as the rest of it uses struct).
> Out of curiosity: is this a fixed number of of integers in that series?
> If so, how many?
> If not, it seems you might be better served if this was an extension
> to the array module.

There are a fixed number of them -- though it's somewhere in the
thousands range... The array module would handle them quite nicely if
it supported 3-byte integers; but in general, a more generic struct
module will be handier than a more generic array module (I've never
dealt with a tuple with thousands of entries before -- is it likely to
be a problem? Anyway, wrapping it in a function to read all the ints
in blocks and put them in a list is very little trouble).

More information about the Python-Dev mailing list