[Python-Dev] Re: [Distutils] Questions about distutils strategy
Tim Peters
tim_one@email.msn.com
Wed, 15 Dec 1999 02:40:11 -0500
[JimA posts his Python rendering of Gary Brown's code]
Yup! That's the zip algorithm, right down to the absurdly bit-reversed
polynomial.
> def crc32(string):
> crc = 0xFFFFFFFF
> for ch in string:
> crc = crc_32_tab[((crc) ^ ord(ch)) & 0xff] ^ (((crc) >> 8) &
> 0xFFFFFF)
> return ~crc
Note that the last line is better (whether in Python or C!) as
return crc ^ 0xffffffff
Else you'll get a surprising result in a 64-bit Python, and in some 64-bit C
implementations.
it's-a-32-bit-algorithm-not-an-"int"-or-"long"-one-ly y'rs - tim