@@ -458,25 +458,6 @@ STATIC mp_obj_t mp_builtin_sorted(mp_uint_t n_args, const mp_obj_t *args, mp_map
458458}
459459MP_DEFINE_CONST_FUN_OBJ_KW (mp_builtin_sorted_obj , 1 , mp_builtin_sorted );
460460
461- STATIC mp_obj_t mp_builtin_id (mp_obj_t o_in ) {
462- mp_int_t id = (mp_int_t )o_in ;
463- if (!MP_OBJ_IS_OBJ (o_in )) {
464- return mp_obj_new_int (id );
465- } else if (id >= 0 ) {
466- // Many OSes and CPUs have affinity for putting "user" memories
467- // into low half of address space, and "system" into upper half.
468- // We're going to take advantage of that and return small int
469- // (signed) for such "user" addresses.
470- return MP_OBJ_NEW_SMALL_INT (id );
471- } else {
472- // If that didn't work, well, let's return long int, just as
473- // a (big) positve value, so it will never clash with the range
474- // of small int returned in previous case.
475- return mp_obj_new_int_from_uint ((mp_uint_t )id );
476- }
477- }
478- MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_id_obj , mp_builtin_id );
479-
480461// See mp_load_attr() if making any changes
481462STATIC inline mp_obj_t mp_load_attr_default (mp_obj_t base , qstr attr , mp_obj_t defval ) {
482463 mp_obj_t dest [2 ];
@@ -523,6 +504,7 @@ STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
523504MP_DEFINE_CONST_FUN_OBJ_2 (mp_builtin_hasattr_obj , mp_builtin_hasattr );
524505
525506// These are defined in terms of MicroPython API functions right away
507+ MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_id_obj , mp_obj_id );
526508MP_DEFINE_CONST_FUN_OBJ_1 (mp_builtin_len_obj , mp_obj_len );
527509MP_DEFINE_CONST_FUN_OBJ_0 (mp_builtin_globals_obj , mp_globals_get );
528510MP_DEFINE_CONST_FUN_OBJ_0 (mp_builtin_locals_obj , mp_locals_get );
0 commit comments