PetaPerl does not support XS (C extensions). Instead, performance-critical
CPAN modules are reimplemented natively in Rust. These “native modules”
provide the same Perl-level API as their XS counterparts but integrate
directly with PetaPerl’s runtime — enabling JIT compilation, auto-parallelization,
and zero FFI overhead.
When you write use List::Util qw(sum min max), PetaPerl’s module loader
detects that List::Util has a native implementation and registers Rust
function pointers directly. There is no compilation step, no .so loading,
and no XS glue code.
Native functions are dispatched via NativeFn — a direct function pointer
with O(1) call overhead, identical to built-in operators.
Native modules run at the same speed as built-in operators since they share
the same dispatch mechanism. For block-taking functions (first, any, all,
reduce), PetaPerl uses MULTICALL optimization to avoid per-element subroutine
call overhead.