From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Roland Orre Newsgroups: gmane.lisp.guile.user Subject: Re: Efficiency and flexibility of hash-tables Date: 08 Feb 2003 14:57:58 +0100 Organization: Royal Institute of Technology Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: <1044712677.1033.143.camel@localhost> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1044712619 7283 80.91.224.249 (8 Feb 2003 13:56:59 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 8 Feb 2003 13:56:59 +0000 (UTC) Cc: guile-user@gnu.org Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18hVTW-0001tL-00 for ; Sat, 08 Feb 2003 14:56:58 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18hVV6-0003Dh-04 for guile-user@m.gmane.org; Sat, 08 Feb 2003 08:58:36 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18hVUe-00039z-00 for guile-user@gnu.org; Sat, 08 Feb 2003 08:58:08 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18hVUb-00039o-00 for guile-user@gnu.org; Sat, 08 Feb 2003 08:58:07 -0500 Original-Received: from smtp0.nada.kth.se ([130.237.222.202] helo=smtp.nada.kth.se) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18hVUa-00034a-00 for guile-user@gnu.org; Sat, 08 Feb 2003 08:58:04 -0500 X-Authentication-Info: Sender authentication was Original-Received: from c600 (h122n2fls33o875.telia.com [217.208.54.122]) (authenticated bits=0) by smtp.nada.kth.se (8.12.1/8.12.1) with ESMTP id h18DvwwV026274 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Sat, 8 Feb 2003 14:57:59 +0100 (MET) Original-To: Joris van der Hoeven In-Reply-To: X-Mailer: Ximian Evolution 1.2.1 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: General Guile related discussions List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.user:1605 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:1605 On Sat, 2003-02-08 at 12:00, Joris van der Hoeven wrote: > Hi, > > When declaring a hash table using > > (define H (make-hash-table 100)) No, the hash table is a vector of entries to lists where the actual information is stored. A hash table in guile can therefore contain any number of items. The number of entries is merely a choice of what performance you need. If you declare too few entries you will get a lot of linear search through the lists from each entry. I myself use to estimate it so that the lists will rarely be deeper than two or three to get a reasonable performance. The performance is also reflected upon the hash function versus the vector length. Usually it is advisable to use a prime number to avoid systematic hashing to the same entries. Sometime it happened I missed this and sloppily declared the hash table length to e.g. 1000000 if needing about 3000000 items. The run took several hours instead of the expected half an hour, which I got when changing the length to 1000003. If you have access to some mathematical package like maple there is often a function nextprime which can be helpful. Usually the built-in hash functions works fine but you may also consider making a special hash functions for special needs if the built-in function doesn't spread good enough. Best regards Roland Orre > > does this mean that the number of slots will *always* remain 100? > > I am frequently dealing with hash tables where I do not > have a reasonable estimation of number of entires in advance. > In TeXmacs, I therefore implemented a hash table type which > doubles the number of slots each time that the number of entries > becomes larger than a constant times the number of slots > (and divides by two the number of slots when the number of > entries becomes smaller than a constant times the number of slots). > Has a similar system been implemented in (an extension of) guile? > > Thanks for your help, Joris > > > ----------------------------------------------------------- > Joris van der Hoeven > http://www.texmacs.org: GNU TeXmacs scientific text editor > http://www.math.u-psud.fr/~vdhoeven: personal homepage > ----------------------------------------------------------- > > > > _______________________________________________ > Guile-user mailing list > Guile-user@gnu.org > http://mail.gnu.org/mailman/listinfo/guile-user -- _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user