Browse Source

py: Add MICROPY_PY_BUILTINS_FILTER, disable for minimal ports.

Saves 320 bytes on x86.
pull/1434/head
Paul Sokolovsky 9 years ago
parent
commit
22ff397fb1
  1. 1
      minimal/mpconfigport.h
  2. 2
      py/modbuiltins.c
  3. 5
      py/mpconfig.h
  4. 4
      py/objfilter.c
  5. 2
      py/qstrdefs.h
  6. 1
      unix/mpconfigport_minimal.h

1
minimal/mpconfigport.h

@ -24,6 +24,7 @@
#define MICROPY_PY_BUILTINS_BYTEARRAY (0)
#define MICROPY_PY_BUILTINS_MEMORYVIEW (0)
#define MICROPY_PY_BUILTINS_ENUMERATE (0)
#define MICROPY_PY_BUILTINS_FILTER (0)
#define MICROPY_PY_BUILTINS_FROZENSET (0)
#define MICROPY_PY_BUILTINS_REVERSED (0)
#define MICROPY_PY_BUILTINS_SET (0)

2
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

5
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)

4
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

2
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

1
unix/mpconfigport_minimal.h

@ -50,6 +50,7 @@
#define MICROPY_PY_BUILTINS_MEMORYVIEW (0)
#define MICROPY_PY_BUILTINS_COMPILE (0)
#define MICROPY_PY_BUILTINS_ENUMERATE (0)
#define MICROPY_PY_BUILTINS_FILTER (0)
#define MICROPY_PY_BUILTINS_FROZENSET (0)
#define MICROPY_PY_BUILTINS_REVERSED (0)
#define MICROPY_PY_BUILTINS_SET (0)

Loading…
Cancel
Save