[Python-Dev] deque implementation question

2017-07-15 Thread Max Moroz
What would be the disadvantage of implementing collections.deque as a circular array (rather than a doubly linked list of blocks)? My naive thinking was that a circular array would maintain the current O(1) append/pop from either side, and would improve index lookup in the middle from O(n) to O(1).

[Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception

2016-12-13 Thread Max Moroz
Would it be worth ensuring that an exception is ALWAYS raised if a key is added to or deleted from a dictionary during iteration? Currently, dict.__iter__ only raises "RuntimeError" when "dictionary changed size during iteration". I managed to add 1 key and delete 1 key from the dictionary in the