diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-08-20 01:01:56 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-08-20 01:05:11 +0300 |
commit | 22ff397fb11fac323607ef2e51d81a4ed96c2c50 (patch) | |
tree | e87bc9304805023caa719937b2c926ef16c03a30 /py | |
parent | 7f70b60f4d05126a838364ee91d288ec8c47d362 (diff) | |
download | micropython-22ff397fb11fac323607ef2e51d81a4ed96c2c50.tar.gz micropython-22ff397fb11fac323607ef2e51d81a4ed96c2c50.zip |
py: Add MICROPY_PY_BUILTINS_FILTER, disable for minimal ports.
Saves 320 bytes on x86.
Diffstat (limited to 'py')
-rw-r--r-- | py/modbuiltins.c | 2 | ||||
-rw-r--r-- | py/mpconfig.h | 5 | ||||
-rw-r--r-- | py/objfilter.c | 4 | ||||
-rw-r--r-- | py/qstrdefs.h | 2 |
4 files changed, 13 insertions, 0 deletions
diff --git a/py/modbuiltins.c b/py/modbuiltins.c index d0c6130d5f..d9b9b496ef 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -563,7 +563,9 @@ STATIC const mp_map_elem_t mp_module_builtins_globals_table[] = { #if MICROPY_PY_BUILTINS_ENUMERATE { MP_OBJ_NEW_QSTR(MP_QSTR_enumerate), (mp_obj_t)&mp_type_enumerate }, #endif + #if MICROPY_PY_BUILTINS_FILTER { MP_OBJ_NEW_QSTR(MP_QSTR_filter), (mp_obj_t)&mp_type_filter }, + #endif #if MICROPY_PY_BUILTINS_FLOAT { MP_OBJ_NEW_QSTR(MP_QSTR_float), (mp_obj_t)&mp_type_float }, #endif diff --git a/py/mpconfig.h b/py/mpconfig.h index bfa7a1f68d..ce6fa6ceae 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -500,6 +500,11 @@ typedef double mp_float_t; #define MICROPY_PY_BUILTINS_EXECFILE (0) #endif +// Whether to support filter function(type) +#ifndef MICROPY_PY_BUILTINS_FILTER +#define MICROPY_PY_BUILTINS_FILTER (1) +#endif + // Whether to support reversed function(type) #ifndef MICROPY_PY_BUILTINS_REVERSED #define MICROPY_PY_BUILTINS_REVERSED (1) diff --git a/py/objfilter.c b/py/objfilter.c index a97c9f554c..9ed37f5986 100644 --- a/py/objfilter.c +++ b/py/objfilter.c @@ -26,6 +26,8 @@ #include "py/runtime.h" +#if MICROPY_PY_BUILTINS_FILTER + typedef struct _mp_obj_filter_t { mp_obj_base_t base; mp_obj_t fun; @@ -66,3 +68,5 @@ const mp_obj_type_t mp_type_filter = { .getiter = mp_identity, .iternext = filter_iternext, }; + +#endif // MICROPY_PY_BUILTINS_FILTER diff --git a/py/qstrdefs.h b/py/qstrdefs.h index ea107f5f47..b95067bbf1 100644 --- a/py/qstrdefs.h +++ b/py/qstrdefs.h @@ -205,7 +205,9 @@ Q(exec) #if MICROPY_PY_BUILTINS_EXECFILE Q(execfile) #endif +#if MICROPY_PY_BUILTINS_FILTER Q(filter) +#endif #if MICROPY_PY_BUILTINS_FLOAT Q(float) #endif |