Skip to content

Commit

Permalink
py/modmicropython: Make module optional.
Browse files Browse the repository at this point in the history
This module is useful, but it is not always needed. Disabling it saves
several kilobytes of build size, depending on other config options.

Signed-off-by: Laurens Valk <laurens@pybricks.com>
  • Loading branch information
laurensvalk authored and dpgeorge committed Dec 6, 2022
1 parent fb7d211 commit f724d90
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions py/modmicropython.c
Expand Up @@ -32,6 +32,8 @@
#include "py/gc.h"
#include "py/mphal.h"

#if MICROPY_PY_MICROPYTHON

// Various builtins specific to MicroPython runtime,
// living in micropython module

Expand Down Expand Up @@ -211,3 +213,5 @@ const mp_obj_module_t mp_module_micropython = {
};

MP_REGISTER_MODULE(MP_QSTR_micropython, mp_module_micropython);

#endif // MICROPY_PY_MICROPYTHON
5 changes: 5 additions & 0 deletions py/mpconfig.h
Expand Up @@ -1311,6 +1311,11 @@ typedef double mp_float_t;
#define MICROPY_PY_CMATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
#endif

// Whether to provide "micropython" module
#ifndef MICROPY_PY_MICROPYTHON
#define MICROPY_PY_MICROPYTHON (1)
#endif

// Whether to provide "gc" module
#ifndef MICROPY_PY_GC
#define MICROPY_PY_GC (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
Expand Down

0 comments on commit f724d90

Please sign in to comment.