[Israel.pm] Article: Optimizing Perl

Yuval Yaari yuval at windax.com
Thu Oct 28 05:13:29 PDT 2004


Shlomo Yona wrote:

> If I recall correctly, it is said in
>     Effective Perl Programming:
>     Writing Better Programs With Perl
>     by Joseph N. Hall, Randal Schwartz that the ',' operator yields 
> faster execution. I don't
> recall why.
>
> I'll need to see the book again to make sure.
> Anyway -- as Gabor said, if you end up needing this kind of
> optimization -- you're doing something wrong.

Great book, we have it around here (at work. And of course, I have it at 
home too), I will look later.
Gabor made a good remark on the subject, but generally knowing that it's 
slower/faster/whatever is always useful.

> Let's see your examples to a 100GB data structure and see if
> the circumstances allow some trick to allow better usage of
> the memory that dramatically reduces swaps.

I don't have a 100GB data-structure, and I would find a way not to load 
it all into memory at once even if I had such data-structure.

> I'll tell you a secret: on some platforms, the Perl garbage
> collector does not take out the trash.... so in fact you
> don't have garbage collection at all!

Perl never frees memory back to the OS (on all platforms, not only 
some), but it reuses it itself.
In the case of circular-references, it won't even do that, because 
REFCNT never reaches zero...
The latest merlyn book has a good example for that on page 122.

  --Yuval



More information about the Perl mailing list