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]

Re: guile extension: python dictionary type


Jay Glascoe <jglascoe@jay.giss.nasa.gov> writes:

 > On 17 Oct 1998, Harvey J. Stein wrote:
 > 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.

/usr/games/primes does it for me at "compile" time when I have an idea
of the needed size.

 > > In any case, I'd say the python hash tables are substantially better
 > > in ease of use because they're resizing.
 >
 > yes.

We're in complete agreement.  I even complained about the hash tables
on this list a few months ago.  I'm glad someone's doing something
about it.

Have you compared python's hash tables to STk's?  STk uses TCL's hash
tables & they seem to be quite fast.  It also includes simple support
for alternate hash functions & comparison fcns.  I'd suggest mimicing
STk's interface (where not incompatible with guile's current
interface) & maybe even just bringing across the code.

 > 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.

A vector of alists indexed by the hashing fcn, to be exact, which is
basically what all hash tables are.

-- 
Harvey J. Stein
BFM Financial Research
hjstein@bfr.co.il