raise takes a long time

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Sun Mar 20 09:55:20 EST 2005


On Fri, 18 Mar 2005 12:04:02 +0000, rumours say that Robin Becker
<robin at reportlab.com> might have written:

>I'm trying to get a handle on a real world problem related to raising an 
>exception. This is in the reportlab SimpleDoctemplate class.
>
>The following code takes a very long time (>60 seconds) in Python 2.2, 2.3, 2.4, 
>but not in 2.1 (at least on windows).
>
>raise LayoutError("Flowable %s too large on page %d" % (f.identity(30), self.page))

Maybe this is dumb, but how long does the following take?

raise LayoutError, "Flowable %s too large on page %d" % (f.identity(30),
self.page)

>However, the supposedly functionally identical code
>
>ident = f.identity(30)
>raise LayoutError("Flowable %s too large on page %d" % (ident, self.page))

Let's not assume that f.identity(30) runs equally fast in the two cases (for any
obscure reasons).  Did you time it (ie get the time at the start and end of the
function)?

>does not take a long time (<< 1 second). The exception LayoutError is trivial
>class LayoutError(Exception):
>     pass

-- 
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...



More information about the Python-list mailing list