From: Hal Fulton Date: 2003-09-16T02:38:26+09:00 Subject: Re: performance and style advice requested 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 > Python can use "tuples", its equivalent of frozen arrays, for that) -- > then I must definitely be very sparing in using hashes with multi-dim > indexes in Ruby, at least in any bottleneck. Thanks! Just the kind of > things I'm trying to learn (I don't remember noticing any such caveat > in Thomas and Hunt's excellent book). 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. Hal