From 970eedce8f37af46cb2b67fa0e91d76c82057541 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 6 Feb 2018 00:06:42 +0200 Subject: 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. --- py/obj.h | 1 + 1 file changed, 1 insertion(+) (limited to 'py/obj.h') diff --git a/py/obj.h b/py/obj.h index 2e715253c..32b430154 100644 --- a/py/obj.h +++ b/py/obj.h @@ -553,6 +553,7 @@ extern const mp_obj_type_t mp_type_list; extern const mp_obj_type_t mp_type_map; // map (the python builtin, not the dict implementation detail) extern const mp_obj_type_t mp_type_enumerate; extern const mp_obj_type_t mp_type_filter; +extern const mp_obj_type_t mp_type_deque; extern const mp_obj_type_t mp_type_dict; extern const mp_obj_type_t mp_type_ordereddict; extern const mp_obj_type_t mp_type_range; -- cgit v1.2.3