<div class="gmail_quote">On Tue, Jul 21, 2009 at 2:21 PM, Lucas P Melo <span dir="ltr"><<a href="mailto:lukepadawan@gmail.com">lukepadawan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I would like to know how much it costs to insert an element into a list using this operation:<br>
a[2:2] = [ 1 ]<br>
i. e, what is the complexity of the operation above (given that len(a) = n)?<br></blockquote></div><br>O(n)<br><br>If you want O(log n), you can use the blist extension type from <a href="http://pypi.python.org/pypi/blist/">http://pypi.python.org/pypi/blist/</a><br>
<blockquote style="margin: 1.5em 0pt;">--<br>
Daniel Stutzbach, Ph.D.<br>
President, <a href="http://stutzbachenterprises.com">Stutzbach Enterprises, LLC</a>
</blockquote>