From 20921f5fba00955a89a272478e754082eaa24375 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 9 Jan 2018 20:41:41 -0500 Subject: [PATCH 1/2] Make chosen features consistent across all boards and ports atmel-samd, esp8266, and nrf. 1. Turn off MICROPY_CPYTHON_COMPAT, which includes a number of minor CPython compatibility features, most of which have workarounds, but uses up significant flash. 2. Turn on MICROPY_PY_SYS_MAXSIZE, which implements sys.maxsize. 3. Turn on MICROPY_CAN_OVERRIDE_BUILTINS, which implements "_" as the most recent value in the REPL, and also enables redefining builtins. --- ports/atmel-samd/mpconfigport.h | 8 ++++---- ports/esp8266/mpconfigport.h | 2 +- ports/nrf/mpconfigport.h | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index f15efca962c09..64a7044f1b372 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -6,13 +6,13 @@ #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_C) // options to control how MicroPython is built - #define MICROPY_QSTR_BYTES_IN_HASH (1) #define MICROPY_ALLOC_PATH_MAX (256) #define MICROPY_ALLOC_PARSE_CHUNK_INIT (16) // TODO(tannewt): Reduce this number if we want the REPL to function under 512 // free bytes. // #define MICROPY_ALLOC_PARSE_RULE_INIT (64) +#define MICROPY_CAN_OVERRIDE_BUILTINS (1) #define MICROPY_EMIT_X64 (0) #define MICROPY_EMIT_THUMB (0) #define MICROPY_EMIT_INLINE_THUMB (0) @@ -20,6 +20,8 @@ #define MICROPY_COMP_CONST (1) #define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1) #define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (1) +// Turn off for consistency +#define MICROPY_CPYTHON_COMPAT (0) #define MICROPY_MEM_STATS (0) #define MICROPY_DEBUG_PRINTERS (0) #define MICROPY_ENABLE_GC (1) @@ -59,6 +61,7 @@ #define MICROPY_PY_URANDOM_EXTRA_FUNCS (0) #define MICROPY_PY_STRUCT (0) #define MICROPY_PY_SYS (1) +#define MICROPY_PY_SYS_MAXSIZE (1) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) #define MICROPY_STREAMS_NON_BLOCK (1) @@ -186,8 +189,6 @@ extern const struct _mp_obj_module_t usb_hid_module; #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (1) #define MICROPY_PY_ALL_SPECIAL_METHODS (1) - #define MICROPY_PY_SYS_MAXSIZE (1) - #define MICROPY_CPYTHON_COMPAT (1) // Scan gamepad every 32ms #define CIRCUITPY_GAMEPAD_TICKS 0x1f @@ -206,7 +207,6 @@ extern const struct _mp_obj_module_t usb_hid_module; #define MICROPY_PY_BUILTINS_COMPLEX (0) #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (0) - #define MICROPY_CPYTHON_COMPAT (0) #endif // Disabled for now. diff --git a/ports/esp8266/mpconfigport.h b/ports/esp8266/mpconfigport.h index c99bc498859e6..479484a43ed65 100644 --- a/ports/esp8266/mpconfigport.h +++ b/ports/esp8266/mpconfigport.h @@ -87,7 +87,7 @@ #define MICROPY_PY_FRAMEBUF (1) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_PY_OS_DUPTERM (1) -#define MICROPY_CPYTHON_COMPAT (1) +#define MICROPY_CPYTHON_COMPAT (0) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 7e23486adbc0c..2f7c19d3a0332 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -81,6 +81,7 @@ #define mp_builtin_open_obj mp_vfs_open_obj #endif +#define MICROPY_CPYTHON_COMPAT (0) #define MICROPY_STREAMS_NON_BLOCK (1) #define MICROPY_MODULE_WEAK_LINKS (1) #define MICROPY_CAN_OVERRIDE_BUILTINS (1) From bb7a6e5c5f1c866e600fe7be101e61dc96d637b3 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 9 Jan 2018 21:19:28 -0500 Subject: [PATCH 2/2] turn on MICROPY_ENABLE_SOURCE_LINE in nrf --- ports/nrf/mpconfigport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 2f7c19d3a0332..e6a331426fe9d 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -43,7 +43,7 @@ #define MICROPY_HELPER_REPL (1) #define MICROPY_REPL_EMACS_KEYS (0) #define MICROPY_REPL_AUTO_INDENT (1) -#define MICROPY_ENABLE_SOURCE_LINE (0) +#define MICROPY_ENABLE_SOURCE_LINE (1) //CP UPDATE: See mpconfigport.h for LONGINT implementation #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #if NRF51