Re: Style help for a Smalltalk-hack

Discussion in 'Python' started by Ian Kelly, Oct 23, 2012.

  1. Ian Kelly

    Ian Kelly Guest

    On Tue, Oct 23, 2012 at 9:13 AM, Travis Griggs <> wrote:
    >
    > On Oct 22, 2012, at 6:33 PM, MRAB <> 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)
     
    Ian Kelly, Oct 23, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Travis Griggs

    Style help for a Smalltalk-hack

    Travis Griggs, Oct 23, 2012, in forum: Python
    Replies:
    0
    Views:
    141
    Travis Griggs
    Oct 23, 2012
  2. MRAB
    Replies:
    0
    Views:
    133
  3. Dennis Lee Bieber

    Re: Style help for a Smalltalk-hack

    Dennis Lee Bieber, Oct 23, 2012, in forum: Python
    Replies:
    0
    Views:
    240
    Dennis Lee Bieber
    Oct 23, 2012
  4. Travis Griggs

    Re: Style help for a Smalltalk-hack

    Travis Griggs, Oct 23, 2012, in forum: Python
    Replies:
    0
    Views:
    165
    Travis Griggs
    Oct 23, 2012
  5. Travis Griggs

    Re: Style help for a Smalltalk-hack

    Travis Griggs, Oct 23, 2012, in forum: Python
    Replies:
    0
    Views:
    164
    Travis Griggs
    Oct 23, 2012
Loading...

Share This Page