deque as default list behaviour
Chris Angelico
rosuav at gmail.com
Sun Mar 3 06:34:04 EST 2019
On Sun, Mar 3, 2019 at 10:12 PM Abdur-Rahmaan Janhangeer
<arj.python at gmail.com> wrote:
>
> i can be wrong but i guess that inserting at the begining does not cause troubles as insertion at index 0 is constant (time does not scale with number of data)
>
In a deque? Correct. But the price of that is reduced efficiency in
other areas. A Python list is *not* efficient for inserting at index
0, but is compact and fast for other, more common operations.
If you want a deque, you know where to find it. The list is not like
that though.
ChrisA
More information about the Python-list
mailing list