Author cmcqueen1975
Recipients cmcqueen1975, dtorp, josiahcarlson, mark.dickinson, tim.peters
Date 2010-01-27.00:38:45
SpamBayes Score 5.04927e-05
Marked as misclassified No
Message-id <1264552727.16.0.225292370736.issue1205239@psf.upfronthosting.co.za>
In-reply-to
Content
Thanks, good points. I'm thinking with a C background and the fixed-width data types. The 0xFF could be needed if the data_byte is actually a larger number and you need to ensure only the lowest 8 bits are set. Or, if there is some sign-extending going on with the right-shift. That could happen in Python if the user passed a negative 'crc' in to the function (for whatever reason).

Yes, I'm missing a final mask. Thanks for pointing that out. I was thinking like a C programmer!

As for crc << 8 >> crc_width... the 'crc << 8' could bump an integer into long territory, making calculations slower. E.g.:

    >>> 2**23 << 8 >> 16
    32768L

    >>> 2**23 >> (16 - 8)
    32768
History
Date User Action Args
2010-01-27 00:38:47cmcqueen1975setrecipients: + cmcqueen1975, tim.peters, josiahcarlson, mark.dickinson, dtorp
2010-01-27 00:38:47cmcqueen1975setmessageid: <1264552727.16.0.225292370736.issue1205239@psf.upfronthosting.co.za>
2010-01-27 00:38:46cmcqueen1975linkissue1205239 messages
2010-01-27 00:38:45cmcqueen1975create