[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT2 performance for number crunching
- From: Mike Pall <mikelu-1102@...>
- Date: Wed, 16 Feb 2011 17:39:24 +0100
Philippe Lhoste wrote:
> >Always write constants inline, otherwise they are treated as
> >variables, which generates worse code. And, yes, even plain Lua is
> >able to fold 1/5 into a constant. It's important to write these
> >unambiguously -- FP arithmetic is not associative!
>
> Good to know, but bad programming practice from a formal point of view. :-)
> I always recommend to beginners in programming to replace magic
> numbers with constants, for readability and consistency.
You mean like a21, a31, a32 and so on as in the original code?
Yeah, that improves readability like 1000%. :-)
[The original author used this solely because Python doesn't
fold constants.]
Magic comes sparingly, and any not-so-magical constants might as
well live inline.
--Mike
- References:
- Re: LuaJIT2 performance for number crunching, Leo Razoumov
- Re: LuaJIT2 performance for number crunching, Francesco Abbate
- Re: LuaJIT2 performance for number crunching, Leo Razoumov
- Re: LuaJIT2 performance for number crunching, Francesco Abbate
- Re: LuaJIT2 performance for number crunching, Leo Razoumov
- Re: LuaJIT2 performance for number crunching, Francesco Abbate
- Re: LuaJIT2 performance for number crunching, T T
- Re: LuaJIT2 performance for number crunching, Daurnimator
- Re: LuaJIT2 performance for number crunching, Mike Pall
- Re: LuaJIT2 performance for number crunching, Philippe Lhoste