Re: [Pharo-project] about keys returning a set

2009-12-05 Thread Stéphane Ducasse
See also http://code.google.com/p/pharo/issues/detail?id=1353 in 11071 ;) http://code.google.com/p/pharo/issues/detail?id=1542 This is issue1353 isn't it ? Lukas proposed to keep a Set, but optimize its creation (with extra knowledge that same key hash code is used

Re: [Pharo-project] about keys returning a set

2009-12-05 Thread Stéphane Ducasse
Nicolas in 1354 you change whichClassDefinesClassVar: aString ^self whichSuperclassSatisfies: [:aClass | (aClass classVarNames collect: [:each | each asString]) includes: aString asString] why not

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread Lukas Renggli
Actually the code can be further optimized: Dictionarykeys Answer a Set containing the receiver's keys. | result container | result := Set basicNew setTally: tally array: array copy. container := result array. 1 to: container size do: [ :index |

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread Igor Stasenko
2009/12/4 Lukas Renggli reng...@gmail.com: Actually the code can be further optimized: Dictionarykeys        Answer a Set containing the receiver's keys.        | result container |        result := Set basicNew setTally: tally array: array copy.        container := result array.        1

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread Nicolas Cellier
2009/12/4 Lukas Renggli reng...@gmail.com: Actually the code can be further optimized: Dictionarykeys        Answer a Set containing the receiver's keys.        | result container |        result := Set basicNew setTally: tally array: array copy.        container := result array.        1

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread Henrik Johansen
This merely shows there are no tests testing the keys method of an IdentityDictionary which contains objects for which hash != identityHash... Cheers, Henry On Dec 4, 2009, at 9:06 25AM, Lukas Renggli wrote: keys Answer a Set containing the receiver's keys. | result

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread Henrik Johansen
Never mind, didn't notice IdentityDictionary reimplements keys... :/ On Dec 4, 2009, at 10:10 46AM, Henrik Johansen wrote: This merely shows there are no tests testing the keys method of an IdentityDictionary which contains objects for which hash != identityHash... Cheers, Henry On

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread Henrik Johansen
On Dec 4, 2009, at 9:12 30AM, Igor Stasenko wrote: 2009/12/4 Lukas Renggli reng...@gmail.com: Actually the code can be further optimized: Dictionarykeys Answer a Set containing the receiver's keys. | result container | result := Set basicNew setTally: tally array:

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread Stéphane Ducasse
do you have an idea why people did not use it? Stef On Dec 4, 2009, at 8:58 AM, Lukas Renggli wrote: I wonder if ever something along the following lines was considered? Dictionarykeys Answer a Set containing the receiver's keys. | result | result := Set

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread Stéphane Ducasse
I would really like to get the changes suggested by nicolas so if one of you want to support by sending code it would be cool. We are trying to close some fixed issues (besides working on our little research activities). Stef On Dec 4, 2009, at 8:29 AM, Henrik Sperre Johansen wrote: A small

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread Stéphane Ducasse
I would be curious to see the average length of dictionary keys (except Smalltalk) and see the performance penalty between set and array for the do: Stef 2009/12/4 Lukas Renggli reng...@gmail.com: Actually the code can be further optimized: Dictionarykeys Answer a Set containing

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread Lukas Renggli
I posted these numbers a while ago. In my image the average length of a Dictionary is 10, the average length of a Set is 1.2. Lukas 2009/12/4 Stéphane Ducasse stephane.duca...@inria.fr: I would be curious to see the average length of dictionary keys  (except Smalltalk) and see the

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread Tudor Girba
Using this script: (Dictionary allInstances inject: 0 into: [ :r :e | r + e size ]) / Dictionary allInstances size asFloat I get 14.23 in my image. Using this script: (Set allInstances inject: 0 into: [ :r :e | r + e size ]) / Set allInstances size asFloat I get 0.49 Cheers, Doru On 4 Dec

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread Stéphane Ducasse
this is interesting to see that this is still a guess game. Even with these numbers I cannot evaluate what could be a slowdown/pseed up impact on the complete system. I imgain that the ietration slow down should be minimal and compensated by the creation speed up. May be in the future when

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread Lukas Renggli
Even with these numbers I cannot evaluate what could be a slowdown/pseed up impact on the complete system. I imgain that the ietration slow down should be minimal and compensated by the creation speed up. Yeah, the iteration slowdown should be minimal of using Set vs. Array. What I think is

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread csrabak
Em 04/12/2009 05:58, Lukas Renggli reng...@gmail.com escreveu: I wonder if ever something along the following lines was considered? Dictionarykeys Answer a Set containing the receiver's keys. | result | result := Set basicNew. result setTally: tally array: (array collect: [ :each |

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread Lukas Renggli
Yeah, this was my first attempt, but this implementation is ways slower. The block activations with #collect: matters. My implemebtation only calls primitives or inlined constructs. Not nice to look at, but as fast as it can get. Lukas On Friday, December 4, 2009, csra...@bol.com.br wrote: Em

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread csrabak
I think this last assertion has to be tempered by another statistic: which is the relationship between iteration (a.k.a. uses of) and creation? -- Cesar Rabak Em 04/12/2009 09:48, Stéphane Ducasse stephane.duca...@inria.fr escreveu: this is interesting to see that this is still a guess

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread Nicolas Cellier
See also http://code.google.com/p/pharo/issues/detail?id=1353 http://code.google.com/p/pharo/issues/detail?id=1542 I uploaded a SLICE that just add a few #asSet here and there. Quasi-neutral as long as keys are Set, but enabling a switch to Array for macro benchmarks purposes... May I also push

Re: [Pharo-project] about keys returning a set

2009-12-04 Thread csrabak
I see. . . this is an interesting observation (about the performance penalty) on the issues of going really OO. In retrospect I think (once the concerns about the possibility of changing the semantics of the returned object) this is the way to go. We really need to have a competitive (in

[Pharo-project] about keys returning a set

2009-12-03 Thread Stéphane Ducasse
Nicolas I was discussing with lukas and we would be interested to get your changes to dictionary keys (Ihope that this icorrect since I'm dead) We would like to integrate your changes. Do you have a basis that we could work? Else we can just try in the image directly. Stef

Re: [Pharo-project] about keys returning a set

2009-12-03 Thread Nicolas Cellier
Yes I can have a look. Otherwise, the changes are quite simple: 1) track senders of keys and sometimes senders of senders 2) identify those sending a message not understandable by an Array (add: remove: etc...), insert keys asSet in this case 3) identify thise sending a potential inefficient

Re: [Pharo-project] about keys returning a set

2009-12-03 Thread Stéphane Ducasse
tx On Dec 3, 2009, at 10:13 PM, Nicolas Cellier wrote: Yes I can have a look. Otherwise, the changes are quite simple: 1) track senders of keys and sometimes senders of senders 2) identify those sending a message not understandable by an Array (add: remove: etc...), insert keys asSet in

Re: [Pharo-project] about keys returning a set

2009-12-03 Thread Lukas Renggli
I wonder if ever something along the following lines was considered? Dictionarykeys Answer a Set containing the receiver's keys. | result | result := Set basicNew. result setTally: tally array: (array collect: [ :each | each isNil ifFalse: