Michael G Schwern wrote:

> On Mon, Sep 18, 2000 at 11:01:12AM -0700, Glenn Linderman wrote:
> > One of the big complaints about today's perl objects is their slowness at
> > accessing member data, which is a direct result of hashes being used as the
> > base data type for the underlying member data items.
>
> The speed differences between hashes and arrays are not the problem.
> C<$val = $array[$idx]> and C<$val = $hash{$key}> both cost the same.
> Beyond that, hashes start to lose, but not by much.

OK, thanks for the info.  I'm not an internals guy, but I guess I should have written 
the benchmark.  It just _seemed_ they should be slower, because there is more work to 
do the hashing.  The actual lookup, I agree,
should be the same.

Now while it is _totally_ true from your numbers that the lookup (read reference) 
costs are the same, it would seem that the variability in write references could still 
make this pay off.  The set_const is about 40%
slower for hash, and set_var is about 166% slower.

N.B.  I wonder if the hash accessor is faster because the array accessor is 
referencing past the end of the array?  (not apples to apples here, you use index 0 
everywhere else, and index 1 in the accessor.)

> The real problem is the overhead of accessor method calls.  This by
> far swamps any little fluctuation between hash and array access.

I agree, based on your numbers, that the overhead of accessor method calls is a bigger 
problem, but am not yet sure, based on your numbers for *_set_*, that there wouldn't 
be an observable benefit to this idea.

> I know, lets call it a pseudo-hash!
>
> Been there, done that, worn the scars proudly.

Is _that_ what a pseudo-hash is?  Then it sounds like a good idea.  But maybe there 
are some differences between today's pseudo-hash and my proposal, even though they 
might be similar.  I think mine is pretty general,
and the discussion on this list made it sound like pseudo-hash has some other 
restrictions?

--
Glenn
=====
Even if you're on the right track,
you'll get run over if you just sit there.
                       -- Will Rogers



____________NetZero Free Internet Access and Email_________
Download Now     http://www.netzero.net/download/index.html
Request a CDROM  1-800-333-3633
___________________________________________________________

Reply via email to