By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,446 Members | 2,998 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,446 IT Pros & Developers. It's quick & easy.

raise takes a long time

P: n/a
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

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Fri, 18 Mar 2005 12:04:02 +0000, rumours say that Robin Becker
<ro***@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...
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.