[Python-Dev] Exception and ABCs / issue #12029 (original) (raw)
George-Cristian Bîrzan gcbirzan at gmail.com
Fri May 11 12:33:57 CEST 2012
- Previous message: [Python-Dev] Allow use of sphinx-autodoc in the standard library documentation?
- Next message: [Python-Dev] Exception and ABCs / issue #12029
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
As per http://bugs.python.org/issue12029 , ABC registration cannot be used for exceptions. This was introduced in a commit that fixed a recursion limit problem back in 2008 (http://hg.python.org/cpython/rev/d6e86a96f9b3/#l8.10). This was later fixed in a different way and improved upon in the 2.x branch in http://hg.python.org/cpython/rev/7e86fa255fc2 and http://hg.python.org/cpython/rev/57de1ad15c54 respectively.
Applying the fix from the 2.x branch for doesn't make any tests fail, and it fixes the problem described in the bug report. There are, however, two questions about this:
- Is this a feature, or a bug? I would say that it's a bug, but even if it's not, it has to be documented, since one generally assumes that it will work.
- Even so, is it worth fixing, considering the limited use cases for it? This slows exception type checking 3 times. I added a new test to pybench:
before: TryRaiseExceptClass: 25ms 25ms 0.39us 0.216ms after: TryRaiseExceptException: 31ms 31ms 0.48us 0.214ms
However, that doesn't tell the whole story, since there's overhead from raising the exception. In order to find out how much actually checking slows down the checking, I ran three timeits, with the following code:
try: raise ValueError() except NameError: pass except NameError: pass except ValueError: pass
try: raise ValueError() except NameError: pass except ValueError: pass
try: raise ValueError() except ValueError: pass
Times are in ms: before after 1 528.69 825.38 2 473.73 653.39 3 416.29 496.80 avgdiff 56.23 164.29
The numbers don't change significantly for more exception tests.
-- George-Cristian Bîrzan
- Previous message: [Python-Dev] Allow use of sphinx-autodoc in the standard library documentation?
- Next message: [Python-Dev] Exception and ABCs / issue #12029
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]