comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » HASH makes too many temporaries
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
HASH makes too many temporaries [message #83592] Mon, 18 March 2013 20:30
Bob[4] is currently offline  Bob[4]
Messages: 24
Registered: April 2009
Junior Member
I was really hoping that HASHes would be a nice replacement for structures. I'm quite adept at working with structures but it gets old rebuilding them all the time just to change the size of an array (or dealing with the ugly and error prone PTRs in structure tags). So HASHes seem like a nice change. But there are severe problems with them. I often work with structures with relatively small number of tags (say 10-25) but with some of these tags have large arrays. With HASHes this does not work well since they tend to force you to create lots of temporaries. Here is a very basic example that illustrates the problem:

IDL> h = hash()
IDL> h['arr'] = fltarr(100000000)
IDL> help, h
H HASH <ID=1 NELEMENTS=1>

I've created a HASH and have a large array in it. Later I want to see the details of whats in the array (since the default help is not helpful for this, unlike a structure help):

IDL> help, h['arr']
<Expression> FLOAT = Array[100000000]

Notice by the delay that this simple command caused a temporary of the large array to be formed. If you have more memory than I do on my laptop then make the array larger and you will notice it. This is crazy. The syntax h['arr'] should produce a reference to the array and NOT a new version of the array (this would allow it to be used on the left side of an = as well). If you want to do the simple call above without producing a temporary you have to use:

IDL> arr = h.remove('arr')
IDL> help, arr
ARR FLOAT = Array[100000000]
IDL> h['arr'] = temporary(arr)

Arrgg! I think that HASHes and LISTs were not incorporated into IDL with sufficient thought.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: setcurrent and buffer don't work together?
Next Topic: Storing !NULL in struct

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:42:33 PDT 2025

Total time taken to generate the page: 0.00634 seconds