On Tue, Oct 23, 2012 at 9:13 AM, Travis Griggs <travisgri...@gmail.com> wrote:
>
> On Oct 22, 2012, at 6:33 PM, MRAB <pyt...@mrabarnett.plus.com> wrote:
>
>> Another way you could do it is:
>>
>> while True:
>>    chunk = byteStream.read(4)
>>    if not chunk:
>>        break
>>    ...
>>
>> And you could fetch multiple signatures in one read:
>>
>> signatures = list(struct.unpack('>{}I'.format(valveCount), byteStream.read(4 
>> * valueCount)))
>
> Thanks, both great ideas. Still does the read/decode slightly different 
> between the different sites, but at least it's localized better. Much 
> appreciated.

Another small optimization would be to read the gap and the valveCount together:

chunk = byteStream.read(8)
...
gap, valveCount = struct.unpack('>2l', chunk)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to