py: Implement core of OrderedDict type.
Given that there's already support for "fixed table" maps, which are essentially ordered maps, the implementation of OrderedDict just extends "fixed table" maps by adding an "is ordered" flag and add/remove operations, and reuses 95% of objdict code, just making methods tolerant to both dict and OrderedDict. Some things are missing so far, like CPython-compatible repr and comparison. OrderedDict is Disabled by default; enabled on unix and stmhal ports.
This commit is contained in:
committed by
Damien George
parent
1004535237
commit
0ef01d0a75
@@ -62,7 +62,7 @@ STATIC void module_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
STATIC bool module_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
|
||||
mp_obj_module_t *self = self_in;
|
||||
mp_obj_dict_t *dict = self->globals;
|
||||
if (dict->map.table_is_fixed_array) {
|
||||
if (dict->map.is_fixed) {
|
||||
#if MICROPY_CAN_OVERRIDE_BUILTINS
|
||||
if (dict == &mp_module_builtins_globals) {
|
||||
if (MP_STATE_VM(mp_module_builtins_override_dict) == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user