jedie/python-ping — pull request #19 by frafra (2012-08-09 17:10:53+00:00)
Title: Improvements in checksum creation

This code is way faster (at least about ~1.5x for a 8 bytes checksum and ~10x for a 128 bytes checksum - Linux, little endian) and cleaner. It seems also correct, which is also a nice feature :) I've not tested it on a big endian cpu, but it should work (see http://docs.python.org/library/array.html#array.array.byteswap)

Also, I've changed "sum" with "val": sum is a reserved word. It's not a beautiful name, but now you can use sum() during checksum creation without problems (otherwise Python gives you an UnboundLocalError).