[Python-Dev] with_traceback (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Thu Mar 1 03:36:33 CET 2007
- Previous message: [Python-Dev] with_traceback
- Next message: [Python-Dev] Weekly Python Patch/Bug Summary
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Adam Olsen wrote:
Exceptions aren't arbitrary objects though. The requirement that they inherit from BaseException is specifically to create a common interface.
But that doesn't tell you enough. If the exception references some other object, should you copy it? You can't tell just from the fact that it inherits from BaseException.
Besides, making a copy of the exception seems just as expensive as creating a new instance, so it does nothing to address the efficiency issue.
Maybe it's not as important as I feel it is, but I like the way that exception raising is lightweight enough to use for flow control. When used that way, creating a new instance each time seems wasteful. I accept the overhead because I know that if it were ever a problem I could eliminate it by pre-creating the instance. I'd be disappointed to lose that ability.
I believe calling copy.copy() would be sufficient.
I never use that, because I have no confidence that it would DWIM. I'd be unhappy if the system started relying on it anywhere fundamental.
-- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | Carpe post meridiem! | Christchurch, New Zealand | (I'm not a morning person.) | greg.ewing at canterbury.ac.nz +--------------------------------------+
- Previous message: [Python-Dev] with_traceback
- Next message: [Python-Dev] Weekly Python Patch/Bug Summary
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]