python - Best data-structure to use for two ended sorted list -


I need a archive data structure that can do the following:

  • Sort
  • Allow me to close and back value
  • enter
  • enter a new value Sort after I>
  • allow a user-specified comparison function, because I am accumulating tuples and want to sort a particular value
  • Thread-protection () However, at this level I think that I need a priority queue and .
  • A hash table, though I do not know if I end the both of the priority queue, then the values ​​can be quickly closed. Another possibility is only maintaining an orderered distribution and making an inclusion It's been, every time I add more data to it, it's a way to go I do.

    Because I am interested in displaying a medium number (I can estimate under 200,000), I am unsure about the uncompressive performance which I need for these tasks. Infinite will not increase, therefore low static performance can be significant as k > * (n) in O (n) . He said, I like that both insert and take the pop operation O (log n) time.

    Besides, does Python have any special implementation? I really would like to avoid writing this code.

You can get good performance for these types of operations or database (such as stdlib In)


Comments