Hi all.
I have the need to store a large (10M) number of keys in a hash table,
based on a tuple of (long_integer, integer). The standard python
dictionary works well for small numbers of keys, but starts to
perform badly for me inserting roughly 5M keys:
# keys dictionary metakit (both using psyco)
------ ---------- -------
1M 8.8s 22.2s
2M 24.0s 43.7s
5M 115.3s 105.4s
Has anyone written a fast hash module which is more optimal for
large datasets ?
p.s. Disk-based DBs are out of the question because most
key lookups will result in a miss, and lookup time is
critical for this application.
Cheers,
Chris
May 15 '06
57 10778
In article <ma***************************************@python. org>,
"Tim Peters" <ti********@gmail.com> wrote: For example, the O(N log N) heapsort is unreasonable compared to the O(N**2) bubblesort by that reasoning (pre-sorted is actually a bad case for heapsort, but a good case for bubblesort)? O(N log N) sorting algorithms helped by pre-existing order are uncommon, unless they do extra work to detect and exploit pre-existing order.
Shellsort works well with nearly-sorted data. It's basically a smarter
version of bubblesort with much improved efficiency. It's also very
compact to implement.
In article <11********************@j55g2000cwa.googlegroups.c om>,
"Iain King" <ia******@gmail.com> wrote: Lawrence D'Oliveiro wrote: In article <44********@nntp0.pdx.net>, Scott David Daniels <sc***********@acm.org> wrote:
>For example, time timsort (Python's internal sort) on pre-sorted >data; you'll find it is handled faster than random data.
But isn't that how a reasonable sorting algorithm should behave? Less work to do if the data is already sorted?
An already sorted list can be pathological for Quicksort, depending on how you code it.
I did say "reasonable". :)
[Tim Peters] ... O(N log N) sorting algorithms helped by pre-existing order are uncommon, unless they do extra work to detect and exploit pre-existing order.
[Lawrence D'Oliveiro] Shellsort works well with nearly-sorted data. It's basically a smarter version of bubblesort with much improved efficiency. It's also very compact to implement.
shellsort is much more a refinement of insertion-sort than of
bubblesort, but is not an O(N log N) algorithm regardlesss. A nice,
succinct summary of what was known about shellsort's behavior as of
Sedgewick's 1996 "Analysis of Shellsort and Related Algorithms" can be
found here: http://www.inf.fh-flensburg.de/lang/...ll/shellen.htm
Tim Peters wrote: shellsort is much more a refinement of insertion-sort than of bubblesort, but is not an O(N log N) algorithm regardlesss.
With a judiciously chosen increment sequence,
the number of comparisons made by shellsort
*is* of the order N log N for practical values of N.
See Figure 8 in http://sun.iinf.polsl.gliwice.pl/~mciura/shellsort.pdf
Marcin
Marcin Ciura wrote: Tim Peters wrote: shellsort is much more a refinement of insertion-sort than of bubblesort, but is not an O(N log N) algorithm regardlesss. With a judiciously chosen increment sequence, the number of comparisons made by shellsort *is* of the order N log N for practical values of N. See Figure 8 in http://sun.iinf.polsl.gliwice.pl/~mciura/shellsort.pdf
That isn't what the reference says. It only covers N up to a few thousand.
Practical values of N need to at least go up into the millions.
Read the summary: Using sequential analysis, the search for optimal increment sequences for Shellsort was accelerated enough to find them for arrays up to several thousand elements.
.... However, the sequences obtained so far are too short to draw a reliable conclusion whether an appropriate sequence of increments can make Shellsort a O(N logN) sorting method on the average. Some hypotheses may be possible when the sequences are prolonged to sort arrays of about 10^5 elements.
Duncan Booth wrote: Marcin Ciura wrote:See Figure 8 in http://sun.iinf.polsl.gliwice.pl/~mciura/shellsort.pdf That isn't what the reference says. It only covers N up to a few thousand. Practical values of N need to at least go up into the millions.
Please look at the performance graph of Tokuda's increment sequence.
You can see that it scales pretty well at least up to 100 million.
Marcin
Marcin Ciura wrote: Duncan Booth wrote: Marcin Ciura wrote:See Figure 8 in http://sun.iinf.polsl.gliwice.pl/~mciura/shellsort.pdf That isn't what the reference says. It only covers N up to a few thousand. Practical values of N need to at least go up into the millions.
Please look at the performance graph of Tokuda's increment sequence. You can see that it scales pretty well at least up to 100 million.
Ah sorry, I misread it. It was sequences with several thousand elements,
which corresponds to N of 100 million.
Thomas Ganss wrote: Klaas schrieb:
4. Insert your keys in sorted order. This advice is questionable - it depends on the at least on the db vendor and probably sometimes on the sort method, if inserting pre-sorted values is better.
The article I wrote that you quoted named a specific vendor (berkeley
db) for which my advice is unquestionable and well-known.
-Mike This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: robin |
last post by:
I need to do a search through about 50 million records, each of which
are less than 100 bytes wide. A database is actually too slow for
this, so I thought of optimising the data and putting it all...
|
by: placid |
last post by:
Hi all,
Just wondering if anyone knows how to pop up the dialog that windows
pops up when copying/moving/deleting files from one directory to
another, in python ?
Cheers
|
by: Gabriel Genellina |
last post by:
En Wed, 30 Jul 2008 21:29:39 -0300, <python@bdurham.comescribi�:
You could use a different hash algorithm yielding a smaller value (crc32,
by example, fits on an integer). At the expense of...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |