[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

RE: [FWP] Moment of Zen




On Thu, 30 Sep 1999 lr@hpl.hp.com wrote:

> > Why sort? Why a temporary variable? And isn't this what makes snooty
> > managerial bastards call us "Perl hacks" and deem Perl unsuitable for
> > anything?
> 
> Why an explicit (slow) loop?
> 
>       my %shares;
>       @shares{keys %sites} = map mindshare($_) => values %sites;

Wouldn't this create a temporary array (the result of map), which would
then get put into the hash? I would think this would be slower because it
involves an extra step, and would also use more memory.

I personally have been a bit appalled by Perl's non-optimization of
unnamed arrays. Try this:

  foreach (1..1000000) { dosomething() }

I don't get why Perl would be allocating an array large enough to hold 1
million numbers. Perhaps there's a valid explanation, but it's pretty
clear what my intent is, and there's no need to allocate a huge array for
this purpose.


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe