[Python-Dev] Re: PEP-317

Steven Taschuk staschuk@telusplanet.net
Tue, 10 Jun 2003 08:51:57 -0600


Quoth Moore, Paul:
  [...]
> But the runtime check has to be done for all uses of the raise
> statement, so that the penalty is incurred not only by people who
> haven't changed their code but also by those who have. [...]

True -- but the present implementation of 'raise' already does the
relevant type-checking: it checks whether a string is being raised
so it can decide whether to issue a PendingDeprecationWarning; it
checks whether a class is being raised so it can decide whether to
implicit instantiate.  (And, of course, any implementation would
have to do *some* type checking in order to decide whether to
raise a TypeError.)  So it's not a new cost.

The only new cost in PEP 317's transition period is the act of
issuing the warning itself, which is not incurred by those using
the One True Syntax, and as argued before, is not usually on a
critical path anyway.  (It is a cost, though; the next revision of
the PEP will mention it.)

(The normal case would actually be simplified under full
implementation of PEP 317, making raises slightly faster; but the
difference will be negligible, I expect, and as before, raises are
only rarely on critical paths.)

-- 
Steven Taschuk                            staschuk@telusplanet.net
"Our analysis begins with two outrageous benchmarks."
  -- "Implementation strategies for continuations", Clinger et al.