On Tue, Jan 21, 2014 at 10:17 PM, Robert Voigtländer <r.voigtlaen...@gmail.com> wrote: > 1. check if a specific item - identified by Node.pos - is in the list. > 2. find the object with the lowest Node.f attribute and update or remove it
Are both those values constant once the Node is added? If so, the easiest way would be to maintain a dictionary mapping pos to the Node (or to a list of Nodes, if you can have multiple with the same pos), and probably heapq for the f values. But if they change, you'll have to update both data structures. If they change often, it's probably not worth maintaining index structures - just search for what you want, when you want it. And if you're working with a small list (say, less than a thousand items), performance isn't going to matter at all, so just do whatever looks cleanest in your code - probably you have that already. ChrisA -- https://mail.python.org/mailman/listinfo/python-list