Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

tsee (4409)

tsee
  reversethis-{gro.napc} {ta} {relleums}
http://steffen-mueller.net/

You can find most of my Open Source Perl software in my CPAN directory [cpan.org].

Journal of tsee (4409)

Saturday November 29, 2008
03:56 PM

Class::XSAccessor - now doing XS constructors

[ #37974 ]

So far, when using Class::XSAccessor or Class::XSAccessor::Array to generate fast accessors implemented in XS for you, you'd still have to write a simple new:


    sub new {
        my $class = shift;
        my $self = bless { @_ } => $class;
        return $self;
    }

So I just added an XS implementation of the above constructor which you can optionally import into your class. The gains are modest compared to the large speedup of the accessors. You gain only something like 40% (without arguments). However, I haven't compared this with any of the heavier method generators out there.

Now, if you think that this kind of micro-optimization is pointless: You're right. Besides being an exercise in XS, this module means that you don't have to spend your time micro-optimizing your simple methods. Everybody knows it's bad, but almost all succumb to the inner voice that makes them do it regardless eventually. With this being done, you can't get much faster, so you don't even have to try!

Cheers,
Steffen

       

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.