Class::XSAccessor - now doing XS constructors

tsee on 2008-11-29T20:56:10

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