3 ms·
Sure. However, instead of reaching into objects to prune them, the better approach is to ask why you're keeping the object around at all. Extracting just the
by jnwatson 6y ago
Sure. However, instead of reaching into objects to prune them, the better approach is to ask why you're keeping the object around at all. Extracting just the parts you want into your own structure is usually the better way to go.
- mikepurvis 6y agoA fair point. The scenario I'm thinking of is with APIs like asyncio.gather, which can be asked to return exception objects rather than re-raise them, for coroutines which fail/raise. This isn't in and of itself a case of long-lived exception objects, but I could see how this approach might lead some users to treat the exception as a long-lived results object, perform type checks against it, etc. If you were in the position of having an app that was set up like this, it would be nice to know you had the option of trimming the Exception's footprint while still allowing it to retain its Exception-ness.