mp_identity(): Add generic identity function.

Useful as getiter method for objects which are their own iterators, etc.
This commit is contained in:
Paul Sokolovsky
2014-01-20 18:37:30 +02:00
parent 3754c4a040
commit dff3f896d7
2 changed files with 8 additions and 0 deletions

View File

@@ -288,3 +288,9 @@ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) {
}
return MP_OBJ_NEW_SMALL_INT(len);
}
// Return input argument. Useful as .getiter for objects which are
// their own iterators, etc.
mp_obj_t mp_identity(mp_obj_t self) {
return self;
}