Tim Peters wrote:
> [EMAIL PROTECTED]
> > Hi, I've written a top-down recursive decent parser for SPICE circuit
> > descriptions.  For debugging purposes, I wanted each production
...
> >  Any clues?
>

> It should go much faster to use a function that doesn't crawl the
> entire call stack.  For example,
>
> >>> import sys, inspect
> >>> def name_of_caller():
> ...     return inspect.getframeinfo(sys._getframe(1), context=0)[2]
> >>> def f():
> ...     print "my name is", name_of_caller()
> >>> f()
> my name is f
>
> name_of_caller() takes time independent of the call-stack depth.
>
> The "context=0" is to avoid wasting time sucking up and packaging
> source-code lines you don't want anyway.


Cool, thanks.  I'll try that.   I didn't realize there were other ways
of getting it.

ms

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to