On Tue, Oct 17, 2000 at 12:13:28PM -0400, John Porter wrote: > Philip Newton wrote: > > > > I believe Perl used to use the native C library's qsort routine, but now has > > its own routine due to the poor behaviour of many "native" qsort > > implementation on pathological comparison functions (that don't return the > > same result given the same inputs). > > I don't think that's the reason. After all, perl's sort is also > not well-behaved under such conditions. In fact, it's one > notorious way to get perl to crash! No, it was mainly about > speed, as the comments say. I don't believe that is correct. The main reason for Perl to use its own implementation of qsort was specifically to avoid the crashes. If Perl crashed during sort because the comparison function was inconsistent, people tended to blame Perl and not the C library. Perl's qsort implementation *does not crash* when the comparison function returns inconsistent results. >From perl5005delta (in 5.6.0): Quicksort is internally implemented Perl now contains its own highly optimized qsort() routine. The new qsort() is resistant to inconsistent comparison functions, so Perl's sort() will not provoke coredumps any more when given poorly written sort subroutines. (Some C library qsort()s that were being used before used to have this problem.) In our testing, the new qsort() required the minimal number of pair-wise compares on average, among all known qsort() implementations. Ronald ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe