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] |
On 17 Oct 1998, Harvey J. Stein wrote: > Jay Glascoe <jglascoe@jay.giss.nasa.gov> writes: > > <snip> > > > 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. > > That wouldn't be fairer, because I'd bet that the python dictionaries > are resizing. yes, the dictionaries resize, the hash tables don't. But as to what's fair and what isn't, well, that's a bit subjective ;) > The only reasonable thing is to compare reasonable usage of both. Since > the guile hashtables aren't resizing, one would typically use a hash > size on the order of the number of elements one expects. Look, I'm approaching Guile from a Perl/Python background. I use hash tables all the time, more often than I use regular arrays. I'm totally addicted to them. It's important, to me, that the table implementation is fast (only a bit slower than a vector), and efficient (e.g., minimal space overhead). I think these Guile hashes really need auto-resizing: (1) I'll often create a hash and really have no idea how much stuff I'm going to throw in there. > Also, if I recall correctly, guile's hash function works better when the > vector has a prime number of elements - 997 might be a much better size > than 1024. (2) I dabbled in number theory quite a bit. But hey man, I can't just conjure up a prime "on the order of the number of elements" every time I make a hash. That's silly. > In any case, I'd say the python hash tables are substantially better > in ease of use because they're resizing. > yes. Actually, to be honest, when I posted that first message I hadn't really understood the nature of Guile's hashes: a vector of alists. Huh. Jay jglascoe@jay.giss.nasa.gov P.S. I plan on using Guile as much as possible. Guess I'd better commit these to memory: 2 + 1 4 + 1 8 + 3 16 + 3 32 + 5 64 + 3 128 + 3 256 + 29 512 + 17 1024 + 9 2048 + 5 4096 + 83 8192 + 27 16384 + 43 32768 + 3 65536 + 45 131072 + 9 262144 + 39 524288 + 39 1048576 + 9 2097152 + 5 4194304 + 3 8388608 + 33 16777216 + 27 33554432 + 9 67108864 + 71 134217728 + 39 268435456 + 9 536870912 + 5 1073741824 + 83 ;)