[Python-3000] The future of exceptions

Brett Cannon brett at python.org
Sun Sep 3 03:34:47 CEST 2006

On 9/2/06, Calvin Spealman <ironfroggy at gmail.com> wrote:
> On 9/2/06, Brett Cannon <brett at python.org> wrote:
> > Right, which is why the original suggestion came up in the first
> place.  It
> > would be nice to compartmentalize exceptions entirely, but the worry of
> > keeping a ont of memory alive for it needs to be addressed, especially
> if
> > exceptions are to be kept lightweight and usable for things other than
> > flagging errors.
> >
> > -Brett
> So, at issue is attaching tracebacks to exceptions keeps too much
> alive and thus makes exceptions too heavy?

Basically.  Memory usage goes up if you do this as it stands now.

If the traceback was passed
> to the exception constructor and then held as an attribute of the
> exception, any exception meant for "light" work (ie., not normal error
> flagging) could simply decided not to include the traceback, and so it
> would be destroyed, removing the weight from the exception. Similarly,
> tracebacks could have some lean() method to drop references to the
> frames.

Problem with that is you then lose any API guarantees of the traceback being
there, which would mean you would still need to keep around sys.exc_info().

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20060902/060a9cf8/attachment.html 

More information about the Python-3000 mailing list