The discussions around Arc as fast as CL and almkglor's suggestion about an optimzing compiler taking data type into consideration (http://arclanguage.org/item?id=4869) made me try something interesting. Actually, it worked even better than I thought (hence the title). Currently, when you write, e.g., (< n 2), it is translated as (ar-funcall2 __< __n 2). Furthermore, < is a polymorphic function (it deals with numbers, strings, ...). Hence a visible slowdown when you do calculations. This is still true (but a little less) when you use the FFI trick I gave in http://arclanguage.org/item?id=4812 : it is still translated as above (with ar-funcall2) and the conversions Scheme <-> C take quite a time. I defined a new set of numeric functions (n+, n-, n, n/, n<, nis, ...) that are hard-wired into their mzscheme counterpart : when (< n 2)* becomes (ar-funcall2 __< __n 2), (n< n 2) becomes (< n 2). Well that's an amazing speedup. (fib 36) in Arc, with <, + and - ->108 s. fib (36) with Python -> 20 s. (fib 36) in Mzscheme -> 8 s. (fib 36) in Arc with n<, n= and n- -> 5 s. Python psyco takes a little more than 1 s. Wow. The idea now would be to automatically translate (type-declaration n 'num
(if (< n 2) ...
into
(if (n< n 2) ...Not that easy, but it should be doable. |