[Israel.pm] cases for using XS code

Shmuel Fomberg shmuelfomberg at gmail.com
Wed Feb 29 23:37:43 PST 2012


Hi David.

Having a C library is certainly a use case.
But also speed - of course XS will be faster then Perl.
That "of course" is assuming that the XS code does not have a lot of
interaction with the Perl code. it should be called, suck its parameters,
do its work and return results.
If you start with callbacks and Perl data manipulation, the speed boost is
not so much.

Also, when you write code in C you have the benefit of using data
structures other the Perl's hash/array/scalar. For example, in one project
I managed to get an additional speed boost due to the fast that I used
trees (STL's map) instead of hashs, I could tranvarse the trees in parallel
instead of tranvarsing one and fetch from the others.

Shmuel.

On Thu, Mar 1, 2012 at 4:25 PM, Michael Gang <michaelgang at gmail.com> wrote:

> Hi all,
>
> When would it be appropriate to write XS code?
> One obvious example is when i have a c library and i want to bind it to
> perl.
> Are there cases when XS code performs better then pure perl code?
> If yes, in which cases?
>
> Thanks,
> David
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://mail.perl.org.il/mailman/listinfo/perl
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.perl.org.il/pipermail/perl/attachments/20120301/e021c275/attachment.htm 


More information about the Perl mailing list