Get current stack depth, performantly.
(size: int = 2)
| 164 | |
| 165 | |
| 166 | def _get_stack_depth(size: int = 2) -> int: |
| 167 | """Get current stack depth, performantly. |
| 168 | """ |
| 169 | frame = sys._getframe(size) |
| 170 | |
| 171 | for size in count(size): |
| 172 | frame = frame.f_back |
| 173 | if not frame: |
| 174 | return size |
| 175 | |
| 176 | |
| 177 | def nearing_recursion_limit() -> bool: |
no outgoing calls
no test coverage detected