473,769 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

raise takes a long time

I'm trying to get a handle on a real world problem related to raising an
exception. This is in the reportlab SimpleDoctempla te 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("Fl owable %s too large on page %d" % (f.identity(30) , self.page))

However, the supposedly functionally identical code

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

does not take a long time (<< 1 second). The exception LayoutError is trivial
class LayoutError(Exc eption):
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
1 1284
On Fri, 18 Mar 2005 12:04:02 +0000, rumours say that Robin Becker
<ro***@reportla b.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 SimpleDoctempla te 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("Fl owable %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("Fl owable %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(Exc eption):
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
2201
by: Tom_OM | last post by:
I have a web site in which I offer freeware programs. They're true freeware, not crippled versions attempting to get people to buy the full versions. The beginning of my user license agreement (agreed to in the install script as a requirement for install -- and also viewable from the app's help menu) states this: "Copyright (C) 2003 by This application is freeware. It may be freely copied and used at no charge so long as it is not...
3
1834
by: James Stroud | last post by:
Hello All, Is this a bug? Why is this tuple getting unpacked by raise? Am I missing some subtle logic? Why does print not work the same way as raise? Both are statements. Why does raise need to be so special? py> sometup = 1,2 py> print sometup (1, 2) py> print 1,2,3, sometup
3
1980
by: Dmitry | last post by:
Hi, I have defined interface for COM components which inludes an argument being filled with additional error info, if such occurs. If inside I raise COM Error, I populate that parameter. In COM environment this architecture works beautifully -- caller application gets negative HRESULT and error description from IErrorInfo object, and additional "log" information from that "ref" parameter: In .Net it just never returns that paramter...
22
1560
by: Scot | last post by:
I have the following code: Dim IP, domainName As String domainName = "yahoo.com" Try IP = System.Net.Dns.GetHostByName(domainName).AddressList(0).ToString() Catch ex As Exception IP = "Not Valid" End Try
7
1711
by: Bruce D | last post by:
My program in connecting to a web site and I want to know how long it takes to connect to this site. I'm assuming I need to use some sort of timer. This is a console application. Here are the lines of code. ' set some time var Dim lWebRequest As System.Net.WebRequest = System.Net.WebRequest.Create(lURL) lWebRequest.Timeout = lTimeOut Dim lWebResponse As System.Net.WebResponse = lWebRequest.GetResponse() ' set second time var and...
7
1171
by: Steven W. Orr | last post by:
In my class I have class Error(Exception): """Base class for exceptions in this module.""" pass class TransitionError(Error): """Raised when an operation attempts a state transition that's not allowed.
3
2135
by: =?Utf-8?B?Ulc=?= | last post by:
I constructed a new Class with some private members. I would like an event to be raised on the moment the value of one of those private members is changed. How do I define an event for that private member and how do I raise the event? -- RW
6
2104
by: Charles Law | last post by:
I have a data table with ~1000 rows. I go through the rows one at a time, checking the contents. If I find a cell with an error, e.g containing null, I use SetColumnError on the data row to flag it. Here's my code: For Each dr As DataRow In MyDataTable.Rows Dim MyValue As Integer If dr("ID").Equals(DBNull.Value) Then
14
4358
by: Rafe | last post by:
Hi, I've encountered a problem which is making debugging less obvious than it should be. The @property decorator doesn't always raise exceptions. It seems like it is bound to the class but ignored when called. I can see the attribute using dir(self.__class__) on an instance, but when called, python enters __getattr__. If I correct the bug, the attribute calls work as expected and do not call __getattr__. I can't seem to make a simple...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10212
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.