Checksum code

Peter Hansen peter at engcorp.com
Tue May 28 07:41:27 EDT 2002


Robin Becker wrote:
> 
> In article <mailman.1022527003.5694.python-list at python.org>,
> jepler at unpythonic.net writes
> ......
> >It looks like the following version would "work" in 1.5.2 and 2.2:
> >    def _add32(x, y):
> >       return (0L+x+y) & 0xFFFFFFFFl
> >the math again becomes math on longs, and the & restricts to 32 bits
> >(intermediate results are calculated with more bits and cut down to
> >size here)
> >
> >Jeff
> .....
> yes I think you're right this works in Python. It's pretty inefficient,
> but I suppose we need to use C if efficiency becomes an issue. 

I think even in C most of the time I've seen a table of (some)
precalculated values used to speed it up.  Why not do that 
in Python /if/ speed actually becomes a measurable problem?

-Peter



More information about the Python-list mailing list