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


Groups > comp.lang.python > #31948 > unrolled thread

Re: Style help for a Smalltalk-hack

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2012-10-23 11:46 -0600
Last post2012-10-23 11:46 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#31948 — Re: Style help for a Smalltalk-hack

FromIan Kelly <ian.g.kelly@gmail.com>
Date2012-10-23 11:46 -0600
SubjectRe: Style help for a Smalltalk-hack
Message-ID<mailman.2680.1351014449.27098.python-list@python.org>
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)

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web