When trying to understand rsync and the rolling checksum I stumbled upon a small python implementation in some self-hosted corner of the web[0], which I have archived on GH[1] (not the author, but things can vanish quickly, as proved by the bzr repo which went poof[2]).
[0]: https://blog.liw.fi/posts/rsync-in-python/
[1]: https://github.com/lloeki/rsync/blob/master/rsync.py
[2]: https://code.liw.fi/obsync/bzr/trunk/