#apache #archlinux #asterisk #centos #debian #gentoo #haskell #kde #kubuntu #lisp #math #mysql #perl #python #ruby-lang #rubyonrails #suse #ubuntu #vim #wikipedia 0 1 2 3 4 5 6 7 8 9 10 11
Top Prev 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 Next
#ruby-lang
<LoganCapaldo> I would use strings
<mirzapirza__> would probably be cleaner to skip to_sym then
<LoganCapaldo> a symbol is a memory leak :)
<apeiros> n8
<mirzapirza__> they don't get gc'd?
<LoganCapaldo> No, not that they take up an especially large amount of space
<LoganCapaldo> but even so 170K symbols means 170K entries in the symbol table
<LoganCapaldo> its almost like you have two of your hashes instead of one
<mirzapirza__> alright, moving to strings
<argv[]> symbols look nicer though :(
<LoganCapaldo> If you want proof just do Symbol.all_symbols
<LoganCapaldo> Look nicer?
<LoganCapaldo> He's doing .to_sym
<LoganCapaldo> Looks are meaningless in this case <g
<argv[]> well
<argv[]> not if he wants to access dict later?
<mirzapirza__> what about array vs. hash?
<LoganCapaldo> He doesn't know what they are
<LoganCapaldo> I don't see an array being faster than a hash
<LoganCapaldo> the file isn't sorted is it?
<LoganCapaldo> Oh of course its sorted its a dictionary file
<mirzapirza__> i'm pretty sure it is - is there a btree or something in the lib?
<LoganCapaldo> You could do an on-disk binary search and load nothing into memory
<mirzapirza__> ooh
<rixxon> and you could write it in c ;P
<LoganCapaldo> LOL
<mirzapirza__> now, now
<mirzapirza__> i'm trying to keep this simple
<imperator> or store your 170k records in, you know, a database
<rixxon> :)
<LoganCapaldo> Or you could see if the string keys work
<imperator> string keys - not as fun as string cheese
<LoganCapaldo> plus you would have to have been going back and forth between symbols and strings for this app
<LoganCapaldo> why did you convert to symbols in the first place again? :)
<mirzapirza__> good question.
<rixxon> LoganCapaldo: because symbols live in the stack, no?
<LoganCapaldo> rixxon, not very useful if you are doing a bunch of string compares :)
<rixxon> nah but i think he thought it would be :p
<LoganCapaldo> (and I think you mean "are immediate values")
<rixxon> yep, same thing
<LoganCapaldo> well no
<LoganCapaldo> its not
<rixxon> hm ok
<blink> Set for hash speed look ps of unordered items, if you're keeping the data in ruby.
<mirzapirza__> should i be doing dict[word] = true ? or can i identify a loaded word some other way?
<LoganCapaldo> An ivar of an object on the heap can be a symbol for instance
<LoganCapaldo> dict.has_key? word works too
<mirzapirza__> ah, there we go. cleaner!
<LoganCapaldo> You could require 'set' also since you don't need to value part of the hash
<rixxon> then why a hash in the first place o_O
Previous Page Next Page