Hello, On Wed, 29 Apr 2020 13:42:05 +0300 Ram Rachum <[email protected]> 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. > > I was iterating through items of a deque, and in some cases I wanted > to delete an item that I've found. As far as I understand, this is an > operation that should be O(1) in a linked list, but Python only > provides an O(N) way to do that, which is `del d[i]`. > > The same can be said for inserting items in the middle. > > What do you think about adding this to `deque`? The API will be > tricky, admittedly, because you'll have to save some kind of > reference to a cell in the deque. Deque is a data structure which allows efficient insertion/deletion from 2 ends of the structure, period. If you want a different data structure, like linked list, or doubly-linked list, with different set of operations, implement such a data structure (it's trivial, and being done by other people all the time). > Thanks, > Ram. -- Best regards, Paul mailto:[email protected] _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/MPWX45VK5SAG4JMGQ5F73MRLDWDMKNJC/ Code of Conduct: http://python.org/psf/codeofconduct/
