in reply to Re: XS: Converting a data structure in a string
in thread XS: Converting a data structure in a string

I'm not sure this algo is a good candidate for either XS or Inline::C. It's not computationally intensive. There might be a small boost in performance from going to XS, but unless this particular sub has been identified as a bottleneck during profiling and you need to squeeze every last CPU cycle out of it, I'd leave it in Perl.
--
Marvin Humphrey
Rectangular Research ― http://www.rectangular.com
  • Comment on Re^2: XS: Converting a data structure in a string

Replies are listed 'Best First'.
Re^3: XS: Converting a data structure in a string
by tirwhan (Abbot) on Nov 04, 2005 at 17:12 UTC

    Agreed. I was under the impression the OP was trying to dip his toes into mixing C with perl code, and personally the only approach to that which doesn't send me slinking away shamefully is with Inline::C ;-)


    Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan

      I started out with Inline::C, too. The hard part is establishing proficiency with a sufficent number of perlapi macros. Once you have that down, the leap from Inline::C to XS is pretty small.

      --
      Marvin Humphrey
      Rectangular Research ― http://www.rectangular.com
Re^3: XS: Converting a data structure in a string
by cosimo (Hermit) on Nov 06, 2005 at 17:13 UTC
    Thanks for your suggestion.

    This function is already implemented at perl level, and for historical reasons (read: legacy code) it handles Big™ data structures, resulting in 10/15 Mb strings.

    And yes, this function has been selected as good candidate for XS/ Inline::C rewriting through basic profiling.

    I thought it might be a valid experiment to learn XS. Probably I should discard Inline::C as a viable alternative because of internal distribution and servers update issues. Nevertheless I'm going to study Inline::C some more...