mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 11:40:18 +01:00
py/objdeque: Implement ucollections.deque type with fixed size.
So far, implements just append() and popleft() methods, required for a normal queue. Constructor doesn't accept an arbitarry sequence to initialize from (am empty deque is always created), so an empty tuple must be passed as such. Only fixed-size deques are supported, so 2nd argument (size) is required. There's also an extension to CPython - if True is passed as 3rd argument, append(), instead of silently overwriting the oldest item on queue overflow, will throw IndexError. This behavior is desired in many cases, where queues should store information reliably, instead of silently losing some items.
This commit is contained in:
committed by
Damien George
parent
cced43feb8
commit
970eedce8f
@@ -30,6 +30,9 @@
|
||||
|
||||
STATIC const mp_rom_map_elem_t mp_module_collections_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ucollections) },
|
||||
#if MICROPY_PY_COLLECTIONS_DEQUE
|
||||
{ MP_ROM_QSTR(MP_QSTR_deque), MP_ROM_PTR(&mp_type_deque) },
|
||||
#endif
|
||||
{ MP_ROM_QSTR(MP_QSTR_namedtuple), MP_ROM_PTR(&mp_namedtuple_obj) },
|
||||
#if MICROPY_PY_COLLECTIONS_ORDEREDDICT
|
||||
{ MP_ROM_QSTR(MP_QSTR_OrderedDict), MP_ROM_PTR(&mp_type_ordereddict) },
|
||||
|
||||
Reference in New Issue
Block a user