Nicolas Neuss writes:
>
> I tested the whole thing again on my laptop (which was down for some
> time). My favorite is now:
This looks fine to me, except for one thing:
> (dotimes (i 10)
> (loop
> for pos1 of-type fixnum from 1 below (- n 1) do
> (loop
> for pos2 of-type fixnum from (+ pos1 n) by n below (+ pos1 (* n (- n 1)))
> do
> (setf (aref entries pos2)
> (* 0.1111111111
> (+ (aref entries (+ pos2 -1001))
> (aref entries (+ pos2 -1))
> (aref entries (+ pos2 999))
> (aref entries (+ pos2 -1000))
> (aref entries (+ pos2 0))
> (aref entries (+ pos2 1000))
> (aref entries (+ pos2 -999))
> (aref entries (+ pos2 1))
> (aref entries (+ pos2 1001))))))))))
For the big long list of AREFs that are indexed (+ pos2 ...), you're
not giving Python all the type information you have. You declare POS2
to be of type FIXNUM, which is the same as saying
(INTEGER MOST-NEGATIVE-FIXNUM MOST-POSITIVE-FIXNUM). The problem with
that is that if you add 1 to a fixnum, the result is of type
(INTEGER (1+ MOST-NEGATIVE-FIXNUM) (1+ MOST-POSITIVE-FIXNUM)).
Changing the type declaration for POS1 to (INTEGER 1 1000) and POS2 to
(INTEGER 1000 1000000) gives a 10% speedup on the Sun I'm working on.
*But*, the usefulness of precise type declarations shines when you
change the OPTIMIZE SAFETY declaration to 1. The version with FIXNUM
declarations experiences a 37% slowdown, whereas the version with
precise declarations stays the same: meaning that, at SAFETY=1, the
version with precise type declarations runs at 67% the speed of the
FIXNUM version.
At SAFETY=0, I don't know what precise type declarations will buy you
on an architecture designed by drunken monkies, but I'd still give it
a try.
--
/|_ .-----------------------.
,' .\ / | No to Imperialist war |
,--' _,' | Wage class war! |
/ / `-----------------------'
( -. |
| ) |
(`-. '--.)
`. )----'