On Fri, 2014-07-11 at 18:53 +0200, simendsjo via Digitalmars-d wrote:
[…]
> Yes, I was very perplexed when I was profiling and finally found the
> main offender. Unfortunately I don't have the code - it was a project
> done for a past employer back in 2006/2007 (Python 2.4 IIRC).

Ah. In which case the anecdote is only of historical interest since it
says nothing about Python as it is today. 2.7 is way faster than 2.4 and
has far more in it that would like make the code in need of a amendment
anyway – also the way local variables are stored and manipulated has
been changed and improved massively over the intervening time. Moreover
3.4 is way, way better than 2.7 and has so much more in it that a
rewrite would definitely be needed if performance was a factor. Without
the code though there is no data point, so nothing to pursue. Sadly.

[…]
> I think of this as a fault in the compiler. It was quite obvious (to me)
> that nothing else relied on the value so the value didn't have to be
> created on each iteration.

A new variable was not being created on each iteration. Python does not
have block scoping.

This cannot be seen as a fault with the compiler since all the compiler
does is to check syntax and indents and convert your source code into
bytecodes. The compiler does not and must not do any form of amending
the abstract syntax tree (AST). Manipulations of the AST must be in the
source code, cf. MacroPy.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to