Math::Prime::Util has pure-perl and XS implementations of everything, with options to override which to use via the environment variable MPU_NO_XS, and specific documentation on some methods to warn that they will be unusually slow in pure perl. It's a pretty mature and successful distribution, so one worth looking at (though it hasn't had a new release for a while now - I remain hopeful that there will be one soon).
I don't believe it attempts to automate the choice however: as far as I recall, the user decides whether to build the XS, and whether to use it in any given instance. That feels to me like a better approach than having the build process decide for itself - I wouldn't want a module to silently install the pure-perl code and claim success just because it tripped over some trivial, easily-fixed problem building the XS code.
In reply to Re: How to author a module with optional XS
by hv
in thread How to author a module with optional XS
by NERDVANA
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |