On 2/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> On Tue, 27 Feb 2007 13:37:21 +1300, Greg Ewing <[EMAIL PROTECTED]> wrote:
>
> >I don't like that answer. I can think of legitimate
> >reasons for wanting to pre-create exceptions, e.g. if
> >I'm intending to raise and catch a particular exception
> >frequently and I don't want the overhead of creating
> >a new instance each time.
>
> This seems like kind of a strange micro-optimization to have an impact on a 
> language change discussion.  Wouldn't it be better just to optimize instance 
> creation overhead?  Or modify __new__ on your particular heavily-optimized 
> exception to have a free-list, so it can be both correct (you can still 
> mutate exceptions) and efficient (you'll only get a new exception object if 
> you really need it).

It sounds like we should always copy the exception given to raise, and
that not doing so is an optimization (albeit a commonly hit one).

Not arguing for or against, just making an observation.

On second thought, we could check that the refcount is 1 and avoid
copying in the common case of "raise Foo()".  Is reraising common
enough that we need to optimize it?


-- 
Adam Olsen, aka Rhamphoryncus
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to