Time complexity for a sublist in Python
<p>In Python, what is the time complexity when we create a sublist from an existing list?</p>

<p>For example, here data is the name of our existing list and list1 is our sublist created by slicing data.</p>

<pre><code>data = [1,2,3,4,5,6..100,...1000....,10^6] 
list1 = data[101:10^6]
</code></pre>

<p>What is the running time for creating list1?</p>

<pre><code>Is it O(10^6) i.e.O(N), or O(1)?
</code></pre>

<p>Getting a list slice in python is <code>O(M - N)</code> / <code>O(10^6 - 101)</code></p>

<p><a href="https://wiki.python.org/moin/TimeComplexity">Here</a> you can check  python list operations time complexity </p>

<p>By underneath, python lists are represented like arrays. So, you can iterate starting on some index(N) and stopping in another one(M)</p>

python performance list big-o sublist