From 09091ecb8351f62cfd57859dd7e207e90e6bc8a4 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Fri, 10 Jun 2022 08:28:58 +0100 Subject: [PATCH] Enable collections deque for CIRCUITPY_FULL_BUILD I'd like to use `collections.deque`: https://docs.circuitpython.org/en/latest/docs/library/collections.html#collections.deque ...on my RP2040-based Keybow 2040 (https://circuitpython.org/board/pimoroni_keybow2040/). For MicroPython, `collections.deque` is enabled for all `rp2` devices, because they all have `MICROPY_CONFIG_ROM_LEVEL` set to 'extra features': https://github.com/micropython/micropython/blob/cf7d962cf38db296d1ac419fc4d5302b64c59644/ports/rp2/mpconfigport.h#L44 ...which includes `MICROPY_PY_COLLECTIONS_DEQUE` (see https://github.com/micropython/micropython/blob/6bda80d81147217a1d830b99b93d2e35d372e8f9/py/mpconfig.h#L1225-L1227 ). For CircuitPython, it looks like `MICROPY_CONFIG_ROM_LEVEL` defaults to 'core' (`MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES`) and isn't updated against any of the ports, so the only port getting `collections.deque` is the `unix` port, which explcitly sets `MICROPY_PY_COLLECTIONS_DEQUE`: https://github.com/adafruit/circuitpython/blob/6925a001382d41940ea9b412b1d1ba517d9880f9/ports/unix/mpconfigport.h#L134 At Dan Halbert's suggestion... https://github.com/adafruit/circuitpython/pull/6474#issuecomment-1152364768 ... this commit enables `MICROPY_PY_COLLECTIONS_DEQUE` for all builds where `CIRCUITPY_FULL_BUILD` is true - which includes Raspberry Pi: https://github.com/adafruit/circuitpython/blob/6925a001382d41940ea9b412b1d1ba517d9880f9/ports/raspberrypi/mpconfigport.mk#L11 See also: * https://github.com/adafruit/circuitpython/issues/5734 * https://github.com/micropython/micropython/commit/970eedce8f37af46cb2b67fa0e91d76c82057541 which originally added collections.deque to MicroPython --- py/circuitpy_mpconfig.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 24d8fb98ca..973f7caf1d 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -226,6 +226,9 @@ typedef long mp_off_t; #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (CIRCUITPY_FULL_BUILD) #endif +#ifndef MICROPY_PY_COLLECTIONS_DEQUE +#define MICROPY_PY_COLLECTIONS_DEQUE (CIRCUITPY_FULL_BUILD) +#endif #define MICROPY_PY_URE_MATCH_GROUPS (CIRCUITPY_RE) #define MICROPY_PY_URE_MATCH_SPAN_START_END (CIRCUITPY_RE) #define MICROPY_PY_URE_SUB (CIRCUITPY_RE)