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

  • Nomecks
    link
    fedilink
    arrow-up
    1
    ·
    6 months ago

    Ah, sorry. Sets are unique, not ordered. Thanks!

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

      Yeah, I just think it’s kind of odd though. If a language only has lists and hash maps, my go-to is to use a hash map for uniqueness, and sort the list for ordered lists.

      But in Python, it’s backwards where I use the hash map (dict) for ordered data and the set for uniqueness, because hash maps are unordered in most languages I’ve used.