Well, it seems that I wasn't so far away in interpreting your intent.
To me, writing this type of extension in XS seems like a reasonable way of adding new functionality to the core without requiring adding new keywords to the tokeniser and messing with the parser etc. with all the inherent risks that entails.
Never haven written a line of XS, I'm not really in a position to judge, but given the credentials of the author of List::Util, I'd have to assume that he knows what he is doing.
I don't quite follow your point regarding review/testing/maintainance? Isn't any code that get distributed as a part of the core subject to the same scrutiny and mainatainance, be it C/Perl/or XS?
In terms of the performance gain of doing so, in this particular instance a crude benchmark shows that the XS version is approximately 3 times faster than the pure perl version.
P:\test>perl -MList::Util=reduce -MBenchmark=timethis -le" timethis -1, q[ our $t=reduce{ $a + $b } 1 .. 10000; ]; print $t" timethis for 1: 1 wallclock secs ( 1.04 usr + 0.00 sys = 1.04 CPU) @ 35.54/s (n=37) 50005000 P:\test>ren \lib\auto\List\Util\Util.dll *.lld P:\test>perl -MList::Util=reduce -MBenchmark=timethis -le" timethis -1, q[ our $t=reduce{ $a + $b } 1 .. 10000; ]; print $t" timethis for 1: 1 wallclock secs ( 1.19 usr + 0.00 sys = 1.19 CPU) @ 10.07/s (n=12) 50005000
I guess it depends where your coming from, what you have to achieve and how long you have to achieve it, as to whether this level of performance gain is worth the risks.
So, optimizing something that works perfectly well when you have no profiling saying that it takes too long to run...
I'm not sure what you base that on...maybe prior knowledge to which I'm not party. None the less, the any piece of re-usable utility code like this, can and will be used in situations where performance is a priority. It would be impossible to profile every possible use in advance. So, if that code can be made to work 3x faster without compromising its correctess (a criteria that we now know has yet to be achieved under some circumstances), then every future use of it benefits.
Finally, I read everything that you (too infrequently:) post. I realise that you are not cursed with excessive time on your hands as I am. As always, I read what you write, and try to apply my own brand of logic to your assertions and make up my own mind. On some things I agree with you, others I don't. And some, like this, I don't yet have the experience of the subject matter to draw my own conclusions. Where my instincts go against your conclusions, I question, so as to get a clearer picture to aid me in making up my own mind on the subject.
Taking nothing as read is a curse I've suffered from since school, but I wouldn't change it. Reaching my own conclusions has stood me in pretty good stead so far.
In reply to Re: Re^5: An anomaly with List::Util::reduce and/or eval? (XS)
by BrowserUk
in thread An anomaly with List::Util::reduce and/or eval?
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |