How do I use the unpack function?

John Machin sjmachin at lexicon.net
Thu May 15 12:40:37 EDT 2008


On May 16, 2:11 am, Gary Herron <gher... at islandtraining.com> wrote:
> Marlin Rowley wrote:
> > All:
>
> > I've got a script that runs really slow because I'm reading from a
> > stream a byte at a time:
>
> > // TERRIBLE
> > for y in range( height ):
> >         for color in range(4):
> >             for x in range( width ):
> >                 pixelComponent = fileIO.read(4)
> >                 buffer = unpack("!f",pixelComponent)  << unpacks ONE

[snip]
Perhaps the OP might be able to use the Python Imaging Library (PIL)
instead of reinventing an image-file handler.



More information about the Python-list mailing list