A set in python isn't guaranteed to have any specific order. Perhaps maintaining the keys in a separate heapq is what you want?

http://docs.python.org/2/library/heapq.html

Jason


On 7/3/13 6:47 PM, Sam Math wrote:
Thank you. This solution is much quicker, since the list of keys is kept
in order!

On Wednesday, July 3, 2013 8:38:20 PM UTC-5, Volker Braun wrote:

    Keep both a set(<keys>) and a dictionary {key:value}. Insert and
    delete on both to keep them in sync.

    On Wednesday, July 3, 2013 9:24:42 PM UTC-4, Sam Math wrote:

        So as you can see, I'm adding 2 elements (in this case, the
        values are 1... but I have specific values in my program) to the
        dictionary, but removing the "first" (in the sense of its key).
        Calling the "min" function seems to be taking time, which is
        understandable.

--
You received this message because you are subscribed to the Google
Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.




--
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to