Class-Tiny icon indicating copy to clipboard operation
Class-Tiny copied to clipboard

Support for Class::XSAccessor accessors

Open tobyink opened this issue 7 years ago • 8 comments

This six line addition roughly doubles the speed of any accessors that don't have a default by building them with Class::XSAccessor. It has a negligible effect on start up time and memory usage. When Class::XSAccessor is not installed, it has no effect. No extra test cases are provided because the intention is for this to have no detectable effect other than the speed-up.

Possible additional changes: adding Class::XSAccessor as a suggests dependency.

tobyink avatar May 15 '18 11:05 tobyink

Coverage Status

Coverage decreased (-1.5%) to 97.015% when pulling 154e8878214a8de2e5e69dda9a5842a67e4f2e00 on tobyink:master into e19ae204c04a024c6d3836bcc9c6197b6235c34a on dagolden:master.

coveralls avatar May 15 '18 11:05 coveralls

I don't know whether you consider the coverage thing to be a problem. Using Devel::Hide, or maybe an environment variable toggle, it might be possible to test both the XS and PP routes in the same test run. Would you like me to try to add something like that to the test suite and .travis.yml?

tobyink avatar May 21 '18 07:05 tobyink

I don't care about coverage to that degree.

I'm not sure when I'll get a chance to review, but it seems like a good idea.

On Mon, May 21, 2018, 3:15 AM Toby Inkster [email protected] wrote:

I don't know whether you consider the coverage thing to be a problem. Using Devel::Hide, or maybe an environment variable toggle, it might be possible to test both the XS and PP routes in the same test run. Would you like me to try to add something like that to the test suite and .travis.yml?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dagolden/Class-Tiny/pull/26#issuecomment-390572424, or mute the thread https://github.com/notifications/unsubscribe-auth/AHRaavOiWH3WtoV3W9w4jCqk9GigZMj1ks5t0mmagaJpZM4T_Why .

xdg avatar May 21 '18 10:05 xdg

Something that I'd like to figure out before merging this is how to test with/without Class::XSAccessors.

Also need to ensure the prereq is stripped back out in the dist.ini.

xdg avatar Jun 20 '18 22:06 xdg

Could do something like:

my $HAS_XS = !$ENV{PERL_CLASS_TINY_PP}
    && eval { require Class::XSAccessor; 1 };

And write a few test cases which do this right at the top before loading Class::Tiny:

BEGIN { $ENV{PERL_CLASS_TINY_PP} = 1 };

As far as declaring Class::XSAccessor as an optional dependency for Dist::Zilla, I don't know. I don't use DIst::Zilla myself, but I'm certain it can be done.

tobyink avatar Jun 21 '18 00:06 tobyink

I can do the dzil work, that was more a comment to self.

xdg avatar Jun 21 '18 00:06 xdg

Do you think the tests I submitted are sufficient?

tobyink avatar Jul 03 '18 19:07 tobyink

Sorry, haven't had a chance to look. I'm a bit underwater with $work.

xdg avatar Jul 03 '18 20:07 xdg