From: Alex Martelli Date: 2003-09-17T02:51:56+09:00 Subject: Re: performance and style advice requested Hal Fulton wrote: > Alex Martelli wrote: >> Simon Strandgaard wrote: >> ... >> >>>>def comb(x, y) >>>> # combinations of x things y at a time (0 if x<0, y<0, or y>x) >>>> result = $_comb_memo[[x, y]] >>> >>> ^^^^^^ >>> ^^^^^^ >>> >>> very slow!! >>> >>>Ruby converts it the array into a string.. this takes time! >> >> >> Oh my! I had no idea Ruby suffered under such a handicap wrt to Python >> (that arrays had to be converted to strings to index into hashes, while ... > Simon is mistaken here. There may be some kind of > speed hit when storing an array as a hash key, but > the key is definitely stored as an array. Ah! Good to know, thanks -- I was (mistakenly, of course) taking all the pronouncements of the c.l.ruby readership as if they came from Ruby experts -- unless of course corrected by others at the time I got to read them (I always read news and mail backwards in time to cover for that), while Simon's remark had been left unchallenged until now. Still, the move from [x,y] to x<<16+y did accelerate Ruby a bit (while the same change slowed Python down a bit) so it does seem the "some kind of speed hit" may in certain cases be (though not by much) noticeable. Alex