Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31948

Re: Style help for a Smalltalk-hack

References <168DF25C-0C43-45F2-BEDC-17AC4210F207@gmail.com> <5085F3DA.1010809@mrabarnett.plus.com> <409B8DCE-2A8A-4B3D-B760-016A0EAB1FC3@gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2012-10-23 11:46 -0600
Subject Re: Style help for a Smalltalk-hack
Newsgroups comp.lang.python
Message-ID <mailman.2680.1351014449.27098.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Oct 23, 2012 at 9:13 AM, Travis Griggs <travisgriggs@gmail.com> wrote:
>
> On Oct 22, 2012, at 6:33 PM, MRAB <python@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)

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Style help for a Smalltalk-hack Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-23 11:46 -0600

csiph-web