473,289 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 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 1616
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: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.