> On Jul 7, 2020, at 4:46 PM, Michał Marcin Brzuchalski > <michal.brzuchal...@gmail.com> wrote: > > Hi internals, > > following recently added alternative to `token_get_all()` in form of a > dedicated class `PhpToken` > I've made a similar proposal for collecting stack traces by introducing > `StackFrame::getTrace()` > and `StackFrame` which replaces array with keys and values known from > `debug_backtrace()`. > > To compete with easier adoption `StackFrame` implements `ArrayAccess` > giving identical API > to `debug_backtrace()`. > > A test script with deep recursion up to 1M frames uses 50% less memory than > `debug_backtrace()`. > > The RFC is described here https://wiki.php.net/rfc/stack-frame-class > It includes implementation of PoC and tests. > > Cheers, > Michał Marcin Brzuchalski
Yes, excited to see this. Would adding a method that allows getting a specific stack frame rather than the entire trace if you know which on you want take up less memory and/or perform better? Something like StackFrame::getFrame(1) which would be functionally equivalent to StackFrame::getTrace()[1]? -Mike