Psycho question

Erik Max Francis max at
Wed Aug 6 22:59:50 CEST 2008

David C. Ullrich wrote:

> Thanks. I would have guessed that I'd want low-level style code;
> that's the sort of thing I have in mind. In fact the only thing
> that seems likely to come up right now is looping through an
> array of bytes, modifying them. The plan is to use the array
> module first to convert a string or a list to an array, outside
> the accelerated part, then maybe do something like
> for j in range(len(bytes)/3):
>   g = (bytes[3*j] + bytes[3*j+1] + bytes[3*j+2])/3
>   bytes[3*j] = bytes[3*j+1] = bytes[3*j+2] = g

If len(bytes) is large, you might want to use `xrange`, too.  `range` 
creates a list which is not really what you need.

Erik Max Francis && max at &&
  San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
   You and I / We've seen it all / Chasing our hearts' desire
    -- The Russian and Florence, _Chess_

More information about the Python-list mailing list