On 2/27/07, glyph at divmod.com <glyph at divmod.com> wrote: > On Tue, 27 Feb 2007 13:37:21 +1300, Greg Ewing <greg.ewing at canterbury.ac.nz> 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4