Exception raising, and performance implications.

leo leomendoza at gmail.com
Tue Oct 4 10:15:41 EDT 2005


> However, I think the functionality you're asking for is available as
> inspect.currentframe(), and if the implementation is in "C" it may have a tiny
> performance advantage over the Python version.

You're absolutely right, in fact the code snippet from my OP was taken
directly from inspect.currentframe. We're intending on using this in
production, and I'm trying to gauge what the implications may be.

> Python uses exceptions internally, using StopIteration to terminate the
> iterator in a for: loop.

Wow, I was unaware of this. If Python internally uses exceptions, maybe
they aren't as detrimental as I thought.

That said, I will be judiciously profiling my code and measuring as
much as possible, I just wanted to throw this question out to the NG in
case anyone had done this before (and so I can put off learning the
profiler a little bit longer :) )

Thanks all for the replies.




More information about the Python-list mailing list