All parameter passing / subroutine calls involving perl are relatively slow, and conversion to and from C types can probably make XS even slower than pure perl if used naively. The best way to use XS/C is to reduce the number of calls back and forth (IOW, move your iterations to C code, don't loop over XS calls where speed really matters). C compilers are very good at inlining and otherwise optimizing subroutine calls. Perl isn't, really - even though it's overall pretty damn fast compared to some other "scripting" languages I could mention.