I'm a relatively new Python (3) programmer. I have a need for a data structure which seems to combine features of collections.Counter, deque, and set, and was hoping someone with more experience could suggest the most "pythonic" approach.
I have a sparse collection of integer indexes, and need to maintain counts associated with each index -- like a Counter. But I also want to retain an implicit ordering between index:count pairs, so that I can e.g. remove the oldest one without knowing its index - like a deque. Finally I'd like to be able to conveniently check for whether an index is present, like a set. Lastly, in case it matters, I want to use rv_discrete from scypy.stats to select members with probabilty weighted by the count.
Any thoughts much appreciated.