raise takes a long time

R

Robin Becker

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))

However, the supposedly functionally identical code

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

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


The f involved is a table containing other tables, LazyParagraphs etc etc etc. I
will not be able to exhibit an example without a large effort. The method
identity is from the platypus Table and recursively attempts to obtain an
identification string.

Clearly this must be some kind of bug, but is it Python 2.2/3/4 or in our code.
Since the change occurs in 2.1-->2.2 I can think of GC/new style classes etc.

Can anyone advise on what would be a good strategy to illustrate/refine/solve
this problem?
 
C

Christos TZOTZIOY Georgiou

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)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top