there is a very detailed table on python wiki which answers your question.

However, in your particular example you should use enumerate to get an index of an iterable within a loop. like so:

for i, item in enumerate(some_seq):
    bar(item, i)
Answer from SilentGhost on Stack Overflow
🌐
Python
wiki.python.org › moin › TimeComplexity
TimeComplexity
Internally, a list is represented as an array; the largest costs come from growing beyond the current allocation size (because everything must move), or from inserting or deleting somewhere near the beginning (because everything after that must move).
🌐
Reddit
reddit.com › r/python › big o cheat sheet: the time complexities of operations python's data structures
r/Python on Reddit: Big O Cheat Sheet: the time complexities of operations Python's data structures
April 16, 2024 -

I made a cheat sheet of all common operations on Python's many data structures. This include both the built-in data structures and all common standard library data structures.

The time complexities of different data structures in Python

If you're unfamiliar with time complexity and Big O notation, be sure to read the first section and the last two sections. I also recommend Ned Batchelder's talk/article that explains this topic more deeply.

Big O Algorithm Comparison Table (Simple) Oct 28, 2025
r/learnprogramming
8mo ago
Useful Big-O Notation Cheatsheet Aug 3, 2019
r/learnprogramming
6y ago
Big-O Algorithm Complexity Cheat Sheet May 4, 2013
r/compsci
13y ago
More results from reddit.com
Discussions

python - Time complexity of min() and max() on a list of constant size? - Computer Science Stack Exchange
If you use min() or max() on a constant sized list, even in a loop, is the time complexity O(1)? More on cs.stackexchange.com
🌐 cs.stackexchange.com
March 11, 2021
python - How do i check the time complexity of a comprehension - Stack Overflow
I have gone through many blogs regarding python time complexity and posting my doubt: In case of list comprehensions how will the time complexity be analysed? For example: x = [(i,xyz_list.coun... More on stackoverflow.com
🌐 stackoverflow.com
How does python handles the re-ordering of the index when elements are added in the middle or in the beginning of list?
I was wondering if such an operation in Python makes it very slow? ... As can be seen in list time complexity table, insertion into a list is O(n) meaning the insertion time linearly increases as the length of a list increases. More on teamtreehouse.com
🌐 teamtreehouse.com
2
November 6, 2019
What's the time complexity of list access in Python? - Stack Overflow
I'm trying to make a python function as fast as I can. Let's suppose I have a prime list and I'm calling primes[i] n times for the same i. I've the intuition that from a certain value of n, it beco... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Python Morsels
pythonmorsels.com › time-complexities
Python Big O: the time complexities of different data structures in Python - Python Morsels
April 16, 2024 - For example, sets are faster at key lookups than lists, but they have no ordering. Dictionaries are just as fast at key lookups as sets and they maintain item insertion order, but they require more memory. In day-to-day Python usage, time complexity tends to matter most for avoiding loops within loops.
🌐
GeeksforGeeks
geeksforgeeks.org › python › complexity-cheat-sheet-for-python-operations
Complexity Cheat Sheet for Python Operations - GeeksforGeeks
July 12, 2025 - This cheat sheet is designed to ... complexities of common operations for these data structures that help them write optimized and efficient code in Python. Python's list is an ordered, mutable sequence, often implemented as a dynamic array. Below are the time complexities ...
🌐
Medium
medium.com › @ivanmarkeyev › understanding-python-list-operations-a-big-o-complexity-guide-49be9c00afb4
Understanding Python List Operations: A Big O Complexity Guide | by Ivan Markeev | Medium
June 4, 2023 - Appending one list to another in Python takes time proportional · to the length of the list being appended (k). The elements of the second list need to be copied to the first list, resulting in O(k) complexity.
Find elsewhere
🌐
DEV Community
dev.to › iihsan › time-complexity-analysis-of-python-methods-bigo-notations-for-list-tuple-set-and-dictionary-methods-47l9
Time Complexity Analysis of Python Methods: Big(O) Notations for List, Tuple, Set, and Dictionary Methods - DEV Community
January 15, 2024 - For example, list.append(). As the list reserves some memory, so until it is utilized, list.append() gives O(1). However, when the reserved memory is filled, and new memory is required, a new list is created with more space, copying all elements. While this operation is not always constant time, it happens infrequently. So, we refer to it as Amortized constant time. The IN Operator uses linear search with a time complexity of O(n). Thanks for reading! Feel free to like, comment, and share if you find this article valuable. You can check my other articles as well: Mastering Metaclasses in Python using real-life scenarios Use Asynchronous Programming in Python: Don’t Block Entire Thread
🌐
W3Schools
w3schools.com › dsa › dsa_timecomplexity_theory.php
DSA Time Complexity
You can sort the values really fast, by just moving 20 to the end of the list and you are done, right? Algorithms work similarly: For the same amount of data they can sometimes be slow and sometimes fast. So to be able to compare different algorithms' time complexities, we usually look at the worst-case scenario using Big O notation.
🌐
Scaler
scaler.com › home › topics › python › append in python
Python List append() Method with Examples - Scaler Topics
May 16, 2023 - O(1), because lists are randomly accessed so the last element can be reached in O(1) time that's why the time taken to add the new element at the end of the list is O(1). Also, when a list is created in Python, it reserves 32 bits of the contiguous memory location.
🌐
TutorialsPoint
tutorialspoint.com › complexity-cheat-sheet-for-python-operations
Complexity Cheat Sheet for Python Operations
August 7, 2023 - Understanding complexity helps you choose the right data structures and optimize your code. For example, an O(n) algorithm takes twice as long with double input size, while an O(n²) algorithm takes four times longer with double input size. Lists are implemented as dynamic arrays in Python.
🌐
Medium
medium.com › @Sathariels › efficient-coding-understanding-time-complexity-with-python-068f7ddf8ab0
Efficient Coding: Understanding Time Complexity with Python | by Nithilan Kumaran | Medium
September 16, 2024 - For example, accessing an element in a list by its index in Python takes constant time: element = my_list[0]. On the other hand, an algorithm with O(log n) time complexity, known as logarithmic time, becomes more efficient as the input size grows.
🌐
Tekolio
tekolio.com › home › dsa › time complexity › time complexity of algorithms explained with examples
Time Complexity of Algorithms Explained with Examples | Tekolio
July 9, 2023 - Time Complexity of algorithms is the amount of time taken by an algorithm to run, as a function of the length of the input..
🌐
Plain English
python.plainenglish.io › exploring-python-lists-understanding-methods-operations-and-time-complexity-66242073716a
“Exploring Python Lists: Understanding Methods, Operations, and Time Complexity” | by Ewho Ruth | Python in Plain English
December 5, 2024 - The time complexity for accessing an element in a list by index is O(1) Here are some common operations on lists in Python along with real-world examples and their time complexities:
🌐
Quora
quora.com › What-is-the-time-complexity-of-the-pop-function-in-a-Python-list
What is the time complexity of the pop() function in a Python list? - Quora
Answer: Depends upon whether you pop from the end (which is the default when you pass no argument), or pop a specific position (which you can do, by passing an index number). Pop from the end is O(1) of course, but popping a specific position is O(n) because the list elements are then shifted to ...
🌐
LinkedIn
linkedin.com › pulse › measuring-time-complexity-practical-example-python-ronak-jain
"Measuring Time Complexity: A Practical Example in Python"
April 25, 2023 - In this case, the loop runs once for each number in the list, so the time complexity is O(n), where n is the length of the list. To measure this, we can use Python's built-in time module.
🌐
Stack Overflow
stackoverflow.com › questions › 76400486 › time-complexity-for-python-list-comparing
algorithm - Time complexity for python list comparing - Stack Overflow
June 4, 2023 - So, the overall time complexity of the algorithm is O(n). The worst-case scenario occurs when the first non-matching element in the lists is at the end, causing the loop to iterate through all the elements.