On Thu, December 15, 2005 17:54, Haufler, Wayne A wrote: > One of the developers here has the impression /opinion that Perl Hashes > are slow. That was because of the poor performance of the GUI menu of a > particular Perl tool, but I believe the poor performance is due to other > factors. May be able to prove that later. > I could not possibly comment on that as I know nothing about your GUI and/or the way it implements hashes.
> I have browsed through my extensive collection of O'Reilly Perl books, > and websites, but can't seem to find anything to support my contention > that hashes are very efficient, almost as much as arrays, and shouldn't > be avoided. If you have a set of values, the performance you get by inserting, deleting, and looking them up is different between an array and hash. I think I remember that arrays do an O(n) for lookup and deletion, whereas hashes are better ( O(1) ) for these types of ops. So, if the intensive part of your algorithm is in the process of looking up values, hashes should be better than arrays. I do not claim huge experience of large data sets, as what I currently work with involves some clever pattern matching on sliced data. But that's what I remember when I used PERL on large data sets three years ago. > > Am I right? Can anyone point me to supporting material? An article of the PJ with title 'Building a Better Hash with tie' by Dan Schmidt mentions briefly the issues. Your issue might not be about picking up random values efficiently, but it does contain a brief discussion on the pros and cons of arrays and hashes which I liked. Besides, you could easily prove the point by trying both data structures in your code and time them. Unless the internals have changed since the article was written have a look http://www.dfan.org/real/tpj_hash.html Only IMHO and sorry in advance if I misundertood something. -- -- George B. Magklaras Senior Computer Systems Engineer/UNIX Systems Administrator The Biotechnology Centre of Oslo, University of Oslo URL: http://www.biotek.uio.no EMBnet Norway: http://www.biotek.uio.no/EMBNET/