On Sat, Jan 2, 2010 at 6:05 AM, Diez B. Roggisch <de...@nospam.web.de> wrote: > Peng Yu schrieb: >> >> On Thu, Dec 31, 2009 at 11:24 PM, Chris Rebert <c...@rebertia.com> wrote: >>> >>> On Thu, Dec 31, 2009 at 8:47 PM, Peng Yu <pengyu...@gmail.com> wrote: >>>> >>>> I observe that python library primarily use exception for error >>>> handling rather than use error code. >>>> >>>> In the article API Design Matters by Michi Henning >>>> >>>> Communications of the ACM >>>> Vol. 52 No. 5, Pages 46-56 >>>> 10.1145/1506409.1506424 >>>> http://cacm.acm.org/magazines/2009/5/24646-api-design-matters/fulltext >>>> >>>> It says "Another popular design flaw—namely, throwing exceptions for >>>> expected outcomes—also causes inefficiencies because catching and >>>> handling exceptions is almost always slower than testing a return >>>> value." >>>> >>>> My observation is contradicted to the above statement by Henning. If >>>> my observation is wrong, please just ignore my question below. >>>> >>>> Otherwise, could some python expert explain to me why exception is >>>> widely used for error handling in python? Is it because the efficiency >>>> is not the primary goal of python? >>> >>> Correct; programmer efficiency is a more important goal for Python >>> instead. >>> Python is ~60-100x slower than C;[1] if someone is worried by the >>> inefficiency caused by exceptions, then they're using completely the >>> wrong language. >> >> Could somebody let me know how the python calls and exceptions are >> dispatched? Is there a reference for it? > > The source? > > http://python.org/ftp/python/2.6.4/Python-2.6.4.tgz > > These are really deep internals that - if they really concern you - need > intensive studies, not casual reading of introductionary documents. IMHO you > shouldn't worry, but then, there's a lot things you seem to care I > wouldn't... :)
For my own interest, I want understand the run time behavior of python and what details causes it much slower. Although people choose python for its programming efficiency, but sometimes the runtime still matters. This is an important aspect of the language. I'm wondering this is not even documented. Why everybody has to go to the source code to understand it? Are you sure that there is no document that describes how python is working internally (including exceptions)? -- http://mail.python.org/mailman/listinfo/python-list