Here is some more silliness. If you take the #triangle method and turn it into a block closure, as below, in VW it takes almost 10 seconds (on my 333 PII) "c.l.s. benchmark" |sum time triangle result | sum := 0. triangle := [ :int| result := 0. 1 to: int do: [ :i | result := result + i]. result ]. time := Time millisecondsToRun: [ 10000000 timesRepeat: [ sum := sum + (triangle value: 10)]]. ^Array with: sum with: time. If you modify the above code so that the "result" instance variable is a block temp, i.e. triangle := [ :int| | result | result := 0. 1 to: int do: [ :i | result := result + i]. result ]. It executes in under 7 seconds (same as if #triangle were a method on Integer). Something to do with the reification of the block temp I suppose [I only know about this from reading a post by Allen Wirfs-Brock on the Squeak list this am] :) Smalltalk MT does not allow block temps. Does python have closures? That would be interesting to see. Cheers, Steve
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4