Reaching subtrees

Aahz Maruch aahz at netcom.com
Sat Sep 18 11:01:13 EDT 1999


In article <oqyae474m9.fsf at titan.progiciels-bpi.ca>,
=?ISO-8859-1?Q?Fran=E7ois_Pinard?=  <pinard at iro.umontreal.ca> wrote:
>"Darrell" <darrell at dorb.com> écrit:
>>
>> As you know if the tuples don't unpack correctly they throw an exception.
>> Exceptions are slow so doing this on a large scale might be a problem.
>
>I guess they might be slow because they have to somewhat scan the stack
>back to find an exception catcher, but otherwise, if exceptions are caught
>quite early on the stack, do they still have to be slow?  That would be
>a little unfortunate, at least for my case.  I thought that `try:' could
>become an important part of Python writing style.  It should rather not?

try is cheap; except is expensive.  But even "expensive" isn't *that*
bad unless you expect to hit it constantly in a tight loop.  As you note
earlier in your post, Python can express certain kinds of complex ideas
very cleanly and simply, and that's usually worth the degredation in
speed.

Once you've got your basic code in place, Python makes it very easy to
profile your code and modify it to make it faster.  I think you will
rarely find that try/except is a problem.
--
                      --- Aahz (@netcom.com)

Androgynous poly kinky vanilla queer het    <*>      http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6  (if you want to know, do some research)




More information about the Python-list mailing list