raise takes a long time

Robin Becker robin at reportlab.com
Fri Mar 18 07:04:02 EST 2005


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?
-- 
Robin Becker




More information about the Python-list mailing list