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 <[email protected]> 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 > [email protected] > http://mail.perl.org.il/mailman/listinfo/perl >
_______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
