Huge speedup for union WAS: Maxima/Ecl on 32-bit machine cannot evaluate "apply(union, listify({{..}}))"
Subject: Huge speedup for union WAS: Maxima/Ecl on 32-bit machine cannot evaluate "apply(union, listify({{..}}))"
From: Stavros Macrakis
Date: Thu, 4 Sep 2008 19:28:56 -0400
Using this patch (which Barton has now checked in):
:lisp (defun require-set (x context-string) (cond (($setp x) (cdr x))(t
(merror "Function ~:M expects a set, instead found ~:M" context-string x))))
I retested Barton's test case qq: makelist({i},i,1,10000);
XXreduce('union,qq)$; recall that xreduce/apply doesn't work on GCL.
lreduce rreduce tree_reduce
Before 176.40 155.40 0.25
After 25.81 3.89 0.03
Given the continued speed advantage of tree_reduce in many cases (though
I've only tested on GCL), I wonder if we should a) define xreduce as
assuming that the operation is associative, thus allowing it to use any
grouping it prefers; b) use tree_reduce by default when apply is not
available.
By the way, there seems to be some problem with l/rreduce for long lists on
GCL -- I will write up a bug report.
-s