On Oct 19, 7:26 pm, xkenneth <[EMAIL PROTECTED]> wrote:
>    Just a quick question. I want to be able to have a data structure
> that organizes data (timestamps I'm working with) sequentially, so
> that i can easily retrieve the first x amount of timeStamps without
> iterating over a list. My thought was to use a binary tree, am i
> overthinking the problem to try and implement this structure inside of
> python? I was also hoping this would already be done for me.

If you're only iterating once, store your data in a list, and sort it
when you need to iterate. If you only want the n largest (or smallest)
timestamps - as suggested by your question - keep your data in a list,
and use heapq.nlargest (or heapq.nsmallest).

In fact, I'd try these even if you think you really need a binary
tree: it might be fast enough anyway.

--
Paul Hankin

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to