High-performance Ruby: faster Symbol.to_s
Note: updated with suggestion by trans.
1 2 class Symbol 3 def to_s 4 @str_rep || (@str_rep = id2name.freeze) 5 end 6 end
12946 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
1 2 class Symbol 3 def to_s 4 @str_rep || (@str_rep = id2name.freeze) 5 end 6 end
1 2 import miso 3 print miso.get_hal_attr(11) # 104000 for my 6600
1 2 >>> from timeit import Timer 3 >>> t = Timer('md5.new("md5 is not safe").digest()', 'import md5') 4 >>> t.timeit() 5 2.6892227922821803