Add cache version for C code.

Also implements __eq__ and __hash__ methods.