Thanks everybody for your answers, and especially Ricky for finding this
note.

On Wed, Apr 29, 2020 at 2:20 PM Ricky Teachey <ri...@teachey.org> wrote:

> I was playing around with deque today, and there were a couple of
>> operations I wanted to do, that can't really be done efficiently with deque
>> because of its implementation.
>>
>> ...
>>
>> What do you think about adding [O(1) insert and remove] this to `deque`?
>>
>
> _collectionsmodule.c has this note, so it sounds like this is intended to
> be a possibility if there is enough interest:
>
> /* insert(), remove(), and delitem() are implemented in terms of rotate()
>> for simplicity and reasonable performance near the end points.  If for some
>> reason these methods become popular, it is not hard to re-implement this
>> using direct data movement (similar to the code used in list slice
>> assignments) and achieve a performance boost (by moving each pointer only
>> once instead of twice). */
>
>
>
> https://github.com/python/cpython/blob/d16a1520c2b22c3cbde7547937ba283db3e88ff5/Modules/_collectionsmodule.c#L952-L958
>
>
>
> ---
> Ricky.
>
> "I've never met a Kentucky man who wasn't either thinking about going home
> or actually going home." - Happy Chandler
>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/JUOQ6DASMKMV52FKIQYAQQ4MJLYBK4LA/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to