How are exceptions actually implemented in assembly?

hungjunglu hungjunglu at yahoo.com
Wed Jan 23 13:12:40 EST 2002


--- In python-list at y..., Steven Majewski <sdm7g at V...> wrote:
> C doesn't really have exceptions in the language, but the equivalent
> functionality is usually coded in C using setjmp & longjmp (which 
are

Thanks to all that have replied. I was more looking into really low 
level implementation (i.e., single CPU instruction, one level further 
down from setjump/longjmp. That is, all I wanted to know was whether 
it was an interrupt or a jump), because all of a sudden I realized 
that exception handling can have an appreciable cost in resources, 
when routines call routines that call routines, etc. Python exception 
handling is at much higher level, and it charges this cost at that 
level. Not too bad, in a sense, since the underlying C code does not 
necessarily have to propagate the exception handling all the way down 
to assembly. But, it also means that at Python level, exception is 
built into everywhere. That's OK, I guess... compared to other things 
(e.g: variable name look up), exception handling is probably pretty 
cheap in resources/performance.

regards,

Hung Jung






More information about the Python-list mailing list