Trey Hunner writes:

This article is primarily meant to act as a Python time complexity cheat sheet for those who already understand what time complexity is and how the time complexity of an operation might affect your code. For a more thorough explanation of time complexity see Ned Batchelder’s article/talk on this subject.

Read Python Big O: the time complexities of different data structures in Python

  • sugar_in_your_tea@sh.itjust.works
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    6 months ago

    sorted_sequence.index(item)

    Shouldn’t this be O(n log n)? I guess Python doesn’t have a list that stays sorted.

    As a workaround, just use dict keys with no values instead.