Using D

Russel Winder via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 11 09:28:35 PDT 2014


On Fri, 2014-07-11 at 17:43 +0200, simendsjo via Digitalmars-d wrote:
[…]
> A little anecdote.. I once got a 20% speed increase in Python by
> "moving" a variable instantiation outside a tight loop.
>   i = 0
>   # loop here
>     i = something
> 
> rather than
>   # loop here
>     i = something

This is interesting. I can believe there is some performance benefit,
but I am not sure I believe 20% improvement. If you can send me the code
you were using, I would like to do some benchmarking on this.

> The compiler wasn't smart enough to do this.

The Python compiler cannot and will never be able to do any such thing.
Indeed if it did any such thing, it would be an error since it
significantly changes the semantics of the program. Thus not doing this
is not the fault of the compiler.  The fact that you were able to do
this and it appeared to give you the same results just means that the
change in program semantics did not affect your computation. Which is
good, but not something the compiler could determine.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140711/5bbbdee2/attachment.sig>


More information about the Digitalmars-d mailing list