[Vm-dev] Re: [squeak-dev] Squeak vs Python "smack down"
Göran Krampe
goran at krampe.se
Tue Feb 8 23:48:02 UTC 2011
On 02/08/2011 05:26 PM, Eliot Miranda wrote:
> On Tue, Feb 8, 2011 at 5:01 AM, Nicolas Cellier
> <nicolas.cellier.aka.nice at gmail.com
> <mailto:nicolas.cellier.aka.nice at gmail.com>> wrote:
>
>
> 2011/2/8 Levente Uzonyi <leves at elte.hu <mailto:leves at elte.hu>>:
> >
> > On Tue, 8 Feb 2011, Nicolas Cellier wrote:
> >
> >>
> >> Just a detail, Python range(a,b) are semi open [a,b)
> >> think like C for(i=0;i<n; i++)
> >>
> >> In the Smalltalk proc8:withwith:with:with:: the range was
> interpreted as [a,b].
> >> This Smalltalk (and Cog) unfairly perform too much work.
> >
> > And there's another one. In #proc0:block: the loops are (1 to:
> loops) do: instead of 1 to: loops do:.
> >
> >
> > Levente
> >
>
> Yes I noticed, but empty loop time is subtracted.
> I wonder if it makes a difference.
>
>
> There is a huge difference between 1 to: loops do: [:i|] and (1 to:
> loops) do: [:i|]. IIRC the empty block is written as 1 to: loops do: [:i|].
When I did the port I did not try to rewrite the code to "proper
Smalltalk style" since it would then typically not compare the VMs. At
least that was my thought (it was a while since I did this).
So I wrote it with *explicit* creation of Intervals since I presumed
Python created ranges - but perhaps Python... never mind, google tells us:
http://wiki.python.org/moin/PythonSpeed/PerformanceTips#Usexrangeinsteadofrange
Aha! So yes, it was a fair comparison before, but now in Python3 they
don't instantiate the range but create an iterator instead. Then we
should change it too I guess :)
I will make a new version of it.
regards, Göran
More information about the Vm-dev
mailing list