Fix Python 3 compatibility bug.

Python 3 is annoying enough to consider dropping support for it entirely. But we've got it mostly working, so maybe that's too drastic. The problem here is that Python removed `__cmp__` support, so you have to implement all six comparators. There's a decorator to only implement two, but even that's just silly.

Python 3 also removed the `cmp()` builtin.

This patch adds Python 3 specific shims for cmp() and a class you can inherit to make `__cmp__` work.