Fix compare methods and use type_code in __cmp__

The int values for TypeIDs are not compiler implementation specific, right?