[Python-3000] The future of exceptions

Calvin Spealman ironfroggy at gmail.com
Sun Sep 3 02:24:22 CEST 2006


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? 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.


More information about the Python-3000 mailing list