From: Stephen Sykes Date: 2009-08-08T04:44:07+09:00 Subject: [ruby-core:24809] Re: [Feature #1906] Kernel#backtrace: Objectifying Kernel#caller > > Rationale > ========= > > `caller` has two principle uses: > > * Allowing users to display the backtrace at a given point, e.g. `puts caller`. > * Introspection to determine the callpath that lead the current method. > Yes we use exactly this kind of introspection when optimising SQL queries in scrooge ( http://github.com/methodmissing/scrooge/tree/master ). For our purposes we need to determine if one backtrace is different from another - we want to make sure that we optimise each callsite from user code individually. Storing and comparing the output of caller is not ideal for this - those arrays of strings can get large. Currently we hash the top 11 items in the list and store the hash as a signature. But even so dozens (or however deep the stack is) of strings must be created each time by caller anyway - it's not terribly fast. What would be most advantageous to us would be if Backtrace#hash were added, and generated a hash faster without having to create so many strings as is the current case. -Stephen