472,992 Members | 3,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,992 software developers and data experts.

Organizing Sequential Data (TimeStamps) Overthinking?

All,

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.

Regards,
Ken

Oct 19 '07 #1
6 1601
On Oct 19, 7:26 pm, xkenneth <xkenn...@gmail.comwrote:
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

Oct 19 '07 #2
xkenneth wrote:
All,

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.

Regards,
Ken
Sounds a little like premature optimization here. It depends on how many
timestamps you are talking about. Certainly if you have a lot (millions),
you should implement binary search, but I would write code first and if it is
too slow, fix that part.

-Larry
Oct 19 '07 #3
On Oct 19, 11:26 am, xkenneth <xkenn...@gmail.comwrote:
All,

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.
Try heapq.nsmallest().
Raymond
Oct 19 '07 #4
On Oct 19, 11:26 am, xkenneth <xkenn...@gmail.comwrote:
All,

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.
Try heapq.nsmallest().
Raymond
Oct 19 '07 #5
On Oct 19, 11:26 am, xkenneth <xkenn...@gmail.comwrote:
All,

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.
Try heapq.nsmallest().
Raymond
Oct 19 '07 #6
En Fri, 19 Oct 2007 16:17:41 -0300, Raymond Hettinger <py****@rcn.com>
escribió:
Try heapq.nsmallest().
En Fri, 19 Oct 2007 16:20:29 -0300, Raymond Hettinger <py****@rcn.com>
escribió:
Try heapq.nsmallest().
En Fri, 19 Oct 2007 17:22:13 -0300, Raymond Hettinger <py****@rcn.com>
escribió:
Try heapq.nsmallest().

“Just the place for a Snark!” the Bellman cried,
As he landed his crew with care;
Supporting each man on the top of the tide
By a finger entwined in his hair.
“Just the place for a Snark! I have said it twice:
That alone should encourage the crew.
Just the place for a Snark! I have said it thrice:
What I tell you three times is true.”

THE HUNTING OF THE SNARK
an Agony in Eight Fits
by Lewis Carroll

--
Gabriel Genellina

Oct 19 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: lkrubner | last post by:
This might be an idiot question, but how do you group by timestamps by date? I mean, given a large number of timestamps, spanning many months, how do grab them and say how many are from each day?...
0
by: GBartgo | last post by:
Hi everybody, I don't know how to initialize the weight vector of each node in the tree. The input is a set of N data in M dimensions. I have to realize a software based on the article "S-TREE:...
3
by: Jamie | last post by:
Hi, Thanks for the excellent answer to my last question! One more: Does anyone have a method they follow for organizing stylesheets themselves? They seem like they can get bloated and hard to...
10
by: Rada Chirkova | last post by:
Hi, at NC State University, my students and I are working on a project called "self-organizing databases," please see description below. I would like to use an open-source database system for...
5
by: Robert Schuldenfrei | last post by:
Dear NG, I have not heard from anyone about a good book that deals with the concurrency issue in SQL Server using C#. I have PROMISED Nick I would not use record locking and I have used an old...
4
by: Craig G | last post by:
im not too sure how i should be storing the SQL2000 timestamps basically i return a dataset which is used to populate an editable grid. this dataset contains the timestamp. how should i be...
17
by: Timothy.Rybak | last post by:
Hello all, This is my first attempt at an application, so kid gloves are appreciated. I need to make a very simple form that only has a few elements. One is TraceCode - a text field that is...
11
by: Timofmars | last post by:
I'm try to Unload DB2 data from a table into a record sequential file on NT. I can an unload on Mainframe, but it doesn't seem to be an option in NT. In NT, all I can do is export/import. I can...
1
by: Ushach | last post by:
hi, I want to know about Self Organizing maps.T ounderstand the concept ,I need a small example which explains how clustering is done through self organizing maps?If any body implemented it plz...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.