This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
> Is it preferable to hash tables in any particular way? > I did some preliminary timing tests. The python dictionaries seem to be about 50% to 100% faster than guile's hash tables. Guile's hash speed depends a lot on the initial size of the vector. The timing test is below. "lines" is 581 lines from a postscript file. (define do-test (lambda (lines number-times) (do ((i 1 (+ i 1))) ((>= i number-times)) (let ((mydict (make-vector 8))) ;;(let ((mydict (make-pydict))) (for-each (insert-entry mydict) lines))))) (define insert-entry (lambda (mydict) (lambda (line) (let* ((len (string-length line)) (top (inexact->exact (/ len 10)))) (let ((key (string->symbol (substring line 0 top))) (value line)) (hash-set! mydict key value)))))) ;;(pydict-set! mydict key value)))))) With the (make-vector 8), above, the python dictionary is nearly twice as fast as the guile hash. With (make-vector 1024), instead, the python dictionary is 50% faster. The python dictionary's internal hash table has a default initial length of 4. So, maybe (make-vector 4) would be a bit more fair. > - Maciej Stachowiak > Jay Glascoe jglascoe@jay.giss.nasa.gov