aboutsummaryrefslogtreecommitdiff
path: root/py/obj.c
diff options
context:
space:
mode:
authorPaul Sokolovsky2014-01-20 18:37:30 +0200
committerPaul Sokolovsky2014-01-20 18:42:08 +0200
commitdff3f896d7f7ef20762f0be7c8d5aa457c04b71a (patch)
treeb0b6ed8d244e498fd2f3bd9824445d5f3ce6a3cd /py/obj.c
parent3754c4a04035d18b0bbb780fa0aef273e1c8f033 (diff)
mp_identity(): Add generic identity function.
Useful as getiter method for objects which are their own iterators, etc.
Diffstat (limited to 'py/obj.c')
-rw-r--r--py/obj.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/py/obj.c b/py/obj.c
index dd081ee35..7dd9cc0a2 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -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;
+}