This may help in understanding the allocation/insertion times: A hash preallocates a chunk of memory (into 'bins'). When you insert an item, a special value (hash value) is calculated for the item to determine which bin to place it in. This is all done for fast access when dealing with large numbers of items. A list typically doesn't preallocate memory but allocates only when inserting a new item. At least this is true of the hashes and lists that I've written in C++. HTH, Rodney Snell -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 14, 2000 3:15 PM To: [EMAIL PROTECTED] Subject: [REBOL] Re: list values and series operations ... Re:(3) Hello [EMAIL PROTECTED], I did some testing on REBOL/2.2.0.1.1 (Amiga) and here's the results: I allocated a block!, a list! and a hash! of 1024 * 1024 elements, each in a fresh instance of REBOL and noted free memory before and after allocation (all numbers in bytes). block!: 55962072 - 39184656 = 16777416 list!: 55959904 - 30789760 = 25170144 hash!: 55927968 - 39176256 = 16751712 that'll be 16 bytes pr element for blocks and hashes, and 25 bytes for list. Also note that inserting into the hash! seemed to use extra memory (about 1.5 byte/element, but I guess it might depend somewhat on the data?), while inserting into the two other didn't (inserting integer!s). I guess these numbers would be somewhat bigger on 64bit architectures... (twice the memory requeired for pointers). One thing that really surprised me, is that while allocating the block! and hash! took long time enough to notice, list! allocation was instant. Best regards Thomas Jensen On 14-Jun-00, [EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: >>> List!s are actually stored differently from blocks, paths and hashes, >>> so any operation on them requires special code that has not been >>> implemented for all action types. >>> - jim >> >> Maybe the list also uses slightly less storage overhead per element? > > Lists use more storage per element than blocks. I would assume that > hashes use more storage than blocks as well, but I don't know how > they compare to lists. I think that parens use the same storage > method as blocks. > > This is just in my experience, but I would be interested in to know > if I'm right about this. Jim? > > Brian Hawley > >
