py: Make long ints hashable.

Addresses issue #765.
diff --git a/py/objint_longlong.c b/py/objint_longlong.c
index 637d9c3..466b45c 100644
--- a/py/objint_longlong.c
+++ b/py/objint_longlong.c
@@ -55,6 +55,16 @@
 const mp_obj_int_t mp_maxsize_obj = {{&mp_type_int}, INT_MAX};
 #endif
 
+mp_int_t mp_obj_int_hash(mp_obj_t self_in) {
+    if (MP_OBJ_IS_SMALL_INT(self_in)) {
+        return MP_OBJ_SMALL_INT_VALUE(self_in);
+    }
+    mp_obj_int_t *self = self_in;
+    // truncate value to fit in mp_int_t, which gives the same hash as
+    // small int if the value fits without truncation
+    return self->val;
+}
+
 bool mp_obj_int_is_positive(mp_obj_t self_in) {
     if (MP_OBJ_IS_SMALL_INT(self_in)) {
         return MP_OBJ_SMALL_INT_VALUE(self_in) >= 0;