deque as default list behaviour

Chris Angelico rosuav at gmail.com
Sun Mar 3 02:44:45 EST 2019


On Sun, Mar 3, 2019 at 6:17 PM Abdur-Rahmaan Janhangeer
<arj.python at gmail.com> wrote:
>
> simple question; why does the normal list not exhibit a deque behaviour
> (left insertion)?

Because it's a lot less efficient. If you want that behaviour, you CAN
still insert into a list at position zero, but it's going to be slow
on large lists; or if you want it to be efficient, the deque is
available in the standard library.

ChrisA



More information about the Python-list mailing list