From ffe911d228c3b7e35ef6ae775c802cdd05cffa47 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 24 Jul 2014 14:21:37 +0100 Subject: py: Make long ints hashable. Addresses issue #765. --- py/obj.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'py/obj.c') diff --git a/py/obj.c b/py/obj.c index cfebbf346..755da0275 100644 --- a/py/obj.c +++ b/py/obj.c @@ -24,6 +24,7 @@ * THE SOFTWARE. */ +#include #include #include #include @@ -33,6 +34,8 @@ #include "misc.h" #include "qstr.h" #include "obj.h" +#include "mpz.h" +#include "objint.h" #include "runtime0.h" #include "runtime.h" #include "stackctrl.h" @@ -152,6 +155,8 @@ mp_int_t mp_obj_hash(mp_obj_t o_in) { return 1; // needs to hash to same as the integer 1, since True==1 } else if (MP_OBJ_IS_SMALL_INT(o_in)) { return MP_OBJ_SMALL_INT_VALUE(o_in); + } else if (MP_OBJ_IS_TYPE(o_in, &mp_type_int)) { + return mp_obj_int_hash(o_in); } else if (MP_OBJ_IS_STR(o_in) || MP_OBJ_IS_TYPE(o_in, &mp_type_bytes)) { return mp_obj_str_get_hash(o_in); } else if (MP_OBJ_IS_TYPE(o_in, &mp_type_NoneType)) { -- cgit v1.2.3