This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brett.cannon
Recipients brett.cannon
Date 2013-06-08.23:54:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1370735699.37.0.350073873785.issue18170@psf.upfronthosting.co.za>
In-reply-to
Content
This quite possibly won't work because of performance, but I have been wondering how feasible it would be to define as many core exception types as possible in pure Python code and then freeze the module for loading. It would have the benefit of making maintenance easier (e.g. all of the PEP 3151 exceptions would have been simpler to add). It also would make it easier on other VMs by minimizing the number of exceptions that have to be written in their implementation language.

Implementation-wise, it's probably easiest to start with leaf exceptions in the inheritance hierarchy and then slowly port more and more. Any exceptions ported to pure Python would have their PyExc_* variable set to their parent so that the variable is initialized to some exception before any Python code is touched. The real trick will come down to dealing with situations where some specific C API has been exposed (e.g. UnicodeError).

Even if this experiment turns out to be feasible and reasonable in terms of simplifying C code, the other question is performance. If this costs more than a couple percent of overall performance (and quite possibly not even at that expense) this would not be worth it.
History
Date User Action Args
2013-06-08 23:54:59brett.cannonsetrecipients: + brett.cannon
2013-06-08 23:54:59brett.cannonsetmessageid: <1370735699.37.0.350073873785.issue18170@psf.upfronthosting.co.za>
2013-06-08 23:54:59brett.cannonlinkissue18170 messages
2013-06-08 23:54:58brett.cannoncreate