A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-October/038576.html below:

[Python-Dev] Efficient predicates for the standard library)

More informative error messages (Re: [Python-Dev] Efficient predicates for the standard library) More informative error messages (Re: [Python-Dev] Efficient predicates for the standard library)Fred L. Drake, Jr. fdrake at acm.org
Tue Oct 7 22:20:04 EDT 2003
Ian Bicking writes:
 > Personally, I usually add the repr of any interesting arguments to my 
 > exceptions.  But many of Python's exceptions don't do this.  Is there a 
 > reasoning there?  Sometimes the repr of an object can be verbose, or in 
 > getting it you can cause a second error.  Is this the reason for the 
 > lack of information, or is it just an oversight?  Or a differing 
 > opinion on how one should debug things?

Another reason is efficiency.  Some exceptions are raised and caught
within the C code of the interpreter.  For these cases, it is
important that the raise be as efficient as possible, so the
interpreter attempts to avoid instantiation of the exception instance;
this cost was once attributed with a fairly bad performance
degradation when we tried a nicer message for AttributeError that
caused the exception instance to always be created (fixed before
release, of course, IIRC!).

That's not to say that there aren't several places where better
exception messages can't be used effectively.  This is only an issue
for exceptions that are going to be frequently raised and caught in C
code.


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4