summaryrefslogtreecommitdiff
path: root/py/objnamedtuple.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-04-21 14:14:24 +0000
committerDamien George <damien.p.george@gmail.com>2015-04-21 14:14:24 +0000
commit5aa311d33084c24262780cae0a65d748990ce7e1 (patch)
tree88a87ed9e5a5dcd912fb5e0c9a15ab95a6c465d5 /py/objnamedtuple.c
parent23a2b11abf22d434be17cfce1c491fca0e9c58f2 (diff)
py: Add attrtuple object, for space-efficient tuples with attr access.
If you need the functionality of a namedtuple but will only make 1 or a few instances, then use an attrtuple instead.
Diffstat (limited to 'py/objnamedtuple.c')
-rw-r--r--py/objnamedtuple.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c
index 0d1463544..59678afe3 100644
--- a/py/objnamedtuple.c
+++ b/py/objnamedtuple.c
@@ -56,16 +56,9 @@ STATIC mp_uint_t namedtuple_find_field(mp_obj_namedtuple_type_t *type, qstr name
STATIC void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_namedtuple_t *o = o_in;
- mp_printf(print, "%q(", o->tuple.base.type->name);
+ mp_printf(print, "%q", o->tuple.base.type->name);
const qstr *fields = ((mp_obj_namedtuple_type_t*)o->tuple.base.type)->fields;
- for (mp_uint_t i = 0; i < o->tuple.len; i++) {
- if (i > 0) {
- mp_print_str(print, ", ");
- }
- mp_printf(print, "%q=", fields[i]);
- mp_obj_print_helper(print, o->tuple.items[i], PRINT_REPR);
- }
- mp_print_str(print, ")");
+ mp_obj_attrtuple_print_helper(print, fields, &o->tuple);
}
STATIC void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {