8000 py: Make collections module configurable, enabled by default. · lurch/micropython@107c9fb · GitHub
[go: up one dir, main page]

Skip to content

Commit 107c9fb

Browse files
committed
py: Make collections module configurable, enabled by default.
1 parent 1463c1f commit 107c9fb

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

py/builtintables.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ STATIC const mp_map_elem_t mp_builtin_module_table[] = {
132132
#if MICROPY_ENABLE_MOD_IO
133133
{ MP_OBJ_NEW_QSTR(MP_QSTR_io), (mp_obj_t)&mp_module_io },
134134
#endif
135+
#if MICROPY_ENABLE_MOD_COLLECTIONS
135136
{ MP_OBJ_NEW_QSTR(MP_QSTR__collections), (mp_obj_t)&mp_module_collections },
137+
#endif
136138
#if MICROPY_ENABLE_MOD_STRUCT
137139
{ MP_OBJ_NEW_QSTR(MP_QSTR_struct), (mp_obj_t)&mp_module_struct },
138140
#endif

py/modcollections.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "obj.h"
55
#include "builtin.h"
66

7+
#if MICROPY_ENABLE_MOD_COLLECTIONS
8+
79
STATIC const mp_map_elem_t mp_module_collections_globals_table[] = {
810
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR__collections) },
911
{ MP_OBJ_NEW_QSTR(MP_QSTR_namedtuple), (mp_obj_t)&mp_namedtuple_obj },
@@ -25,3 +27,5 @@ const mp_obj_module_t mp_module_collections = {
2527
.name = MP_QSTR__collections,
2628
.globals = (mp_obj_dict_t*)&mp_module_collections_globals,
2729
};
30+
31+
#endif // MICROPY_ENABLE_MOD_COLLECTIONS

py/mpconfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ typedef double mp_float_t;
115115
#define MICROPY_ENABLE_FLOAT (0)
116116
#endif
117117

118+
// Whether to provide "collections" module
119+
#ifndef MICROPY_ENABLE_MOD_COLLECTIONS
120+
#define MICROPY_ENABLE_MOD_COLLECTIONS (1)
121+
#endif
122+
118123
// Whether to provide "math" module
119124
#ifndef MICROPY_ENABLE_MOD_MATH
120125
#define MICROPY_ENABLE_MOD_MATH (1)

py/objnamedtuple.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "obj.h"
88
#include "objtuple.h"
99

10+
#if MICROPY_ENABLE_MOD_COLLECTIONS
11+
1012
typedef struct _mp_obj_namedtuple_type_t {
1113
mp_obj_type_t base;
1214
const char *fields;
@@ -143,3 +145,5 @@ STATIC mp_obj_t new_namedtuple_type(mp_obj_t name_in, mp_obj_t fields_in) {
143145
return mp_obj_new_namedtuple_type(name, fields);
144146
}
145147
MP_DEFINE_CONST_FUN_OBJ_2(mp_namedtuple_obj, new_namedtuple_type);
148+
149+
#endif // MICROPY_ENABLE_MOD_COLLECTIONS

0 commit comments

Comments
 (0)
0