Hi Monks,
I have a module I've written which can be quite computationally expensive depending on how complex the operations used are. You can obviously get speed improvements by working with straight compiled C (depending on what you are doing, assuming same algorithms etc.), but I would like to explore speeding my code by using Perl/C options to see if I can't get it to run like a scared cat in heat (*). I'm not wanting to focus in this post about optimizing a specific routine, but the best information if one wishes to proceed with using Perl/C. From a brief bit of investigating the 3 choices appear to be..

1) XS
2) Inline C
3) SWIG


My question(s) are which is the preferred method and why? Inline C appears to be the 'quick' approach if you've absolutely gotta have some other language code involved and just want to slap it straight into the script. XS appears to require 'a lot' more setup and background reading, but from what I can gather is the way lots of modules seem to be heading.
What do you, the experienced perl community view as the pivotal documents (books, FAQs, posts) on these subjects? I couldn't find an o'reilly animal book on the subject (I really enjoy their format and have about 10 of them).
Basically, I would appreciate any comments on transitioning from straight perl to Perl/C implementation.

Regards Paul

(*) No, I don't have any data to show that this is faster than a normal cat, but I'm postulating that there would be some degree of haste involved =P.

In reply to Perl & C by thekestrel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.