Most pythonic way of rotating a circular list to a canonical point

Paul Rubin at nospam.invalid
Sun Aug 2 04:47:34 CEST 2015

Lukas Barth <mail at> writes:
>> [Concatenated Hashes]
> Also, that still doesn't compute that one "canonical ordering"...

It was intended to get rid of the need.  What is the actual application?

How does this sound?  To circularly hash [a,b,c,d] use:

  H([b-a, c-b, d-c, a-d])

where H is your favorite hash function on a list of that element type.
That should give the same hash value for any rotation of the list.
It generalizes in the obvious way to other lengths.

More information about the Python-list mailing list