View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Руслан У. Закиров > Class-Accessor-Fast-GXS-0.01 > Class::Accessor::Fast::GXS



Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  


Class::Accessor::Fast::GXS - generate C::A::Fast compatible XS accessors


This module allows you to generate a XS code for accessors you need your classes. It's implemented on top of Class::Accessor::Fast and fallbacks to it when it's not possible to access C library.

This code is quite experimental and API for generating XS is not settled down. It's up to you to try and suggest the way you want generator to work.


Setup inheritance from Class::Accessor::Fast::GXS

The top of a Makefile.PL

    BEGIN {
        use Class::Accessor::Fast::GXS;
        local $Class::Accessor::Fast::XS::GENERATE_TO = "TAccessors.xs";
        local $Class::Accessor::Fast::XS::MODULE = "My::TAccessors";
        require "lib/My/";

    use inc::Module::Install;

It generates TAccessors.xs from mk*accessor calls in your modules.

See also example dir in the tarball.


There are some things that must be considered before running this in production:


Module::Install system installs your module into arch specific dirs when it has XS code, I don't think it the right way. I think your module should be installed in the old way except for binary parts.


The current API for generation is kind cryptic still and subject to change.


I think that your modules should still be installable when people have no compiler.

CPU cache

The module may gen a lot of subs in one object file and I have no enough C-fu to say what is the best way to re-organize the code to make object file smaller, CPU cache effective and don't loose overall performance.


Here is comparings:

                       Rate       get_caf get_dummy_sub    get_cafgxs  get_dummy_ha
    get_caf        767999/s            --          -26%          -62%          -80%
    get_dummy_sub 1037900/s           35%            --          -49%          -73%
    get_cafgxs    2016491/s          163%           94%            --          -48%
    get_dummy_ha  3855058/s          402%          271%           91%            --
                           Rate set_one_caf set_one_dummy_sub set_one_cafgxs set_one_dummy_ha
    set_one_caf        568700/s          --              -35%           -72%             -83%
    set_one_dummy_sub  877713/s         54%                --           -57%             -74%
    set_one_cafgxs    2029875/s        257%              131%             --             -39%
    set_one_dummy_ha  3317254/s        483%              278%            63%               --
                             Rate set_multi_caf set_multi_dummy_sub set_multi_cafgxs set_multi_dummy_ha
    set_multi_caf        548746/s            --                 -4%             -74%               -84%
    set_multi_dummy_sub  573439/s            4%                  --             -73%               -83%
    set_multi_cafgxs    2117316/s          286%                269%               --               -38%
    set_multi_dummy_ha  3389792/s          518%                491%              60%                 --
                      Rate       mix_caf mix_dummy_sub    mix_cafgxs  mix_dummy_ha
    mix_caf       195491/s            --          -10%          -68%          -80%
    mix_dummy_sub 216392/s           11%            --          -65%          -78%
    mix_cafgxs    613304/s          214%          183%            --          -39%
    mix_dummy_ha  998734/s          411%          362%           63%            --

Where "caf" is Class::Accessor::Fast, "cafgxs" is generated, "dummy_sub" is a perl sub that do just what we need and nothing else and "dummy_ha" is just dirrect hash access.

See also example dir in the tarball.


Ruslan Zakirov <>


This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: