]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
XEvent.py: Added support for ExposeEvent.
authorSjoerd Mullender <sjoerd@acm.org>
Wed, 25 Aug 1993 14:09:01 +0000 (14:09 +0000)
committerSjoerd Mullender <sjoerd@acm.org>
Wed, 25 Aug 1993 14:09:01 +0000 (14:09 +0000)
profile.py: Some speed improvements (I hope).
rect.py: Bug fix in union().

Lib/lib-stdwin/rect.py
Lib/profile.py
Lib/stdwin/rect.py

index 9bc63421162a42a0c0a4a41bc2efc949d6dd4dfb..393eafd7692da08424dad18ea8fcc5ddc354d48c 100644 (file)
@@ -46,7 +46,7 @@ def intersect(list):
 # This works with a list or tuple argument.
 #
 def union(list):
-       (left, top), (right, bottom) = empty
+       (left, top), (right, bottom) = list[0]
        for (l, t), (r, b) in list[1:]:
                if not is_empty(((l, t), (r, b))):
                        if l < left: left = l
index a965f952557781a5e56593f6888f766c14c771a5..000e79a090c7f84c3b3415df9e9b49a0535e8ff1 100755 (executable)
@@ -36,20 +36,29 @@ class Profile:
                                self.profiling = 1
                        t = os.times()
                        t = t[0] + t[1]
-                       lineno = codehack.getlineno(frame.f_code)
-                       filename = frame.f_code.co_filename
-                       key = filename + ':' + `lineno` + '(' + funcname + ')'
+                       if frame.f_locals.has_key('__key'):
+                               key = frame.f_locals['__key']
+                       else:
+                               lineno = codehack.getlineno(frame.f_code)
+                               filename = frame.f_code.co_filename
+                               key = filename + ':' + `lineno` + '(' + funcname + ')'
+                               frame.f_locals['__key'] = key
                        self.call_level = depth(frame)
                        self.cur_frame = frame
                        pframe = frame.f_back
                        if self.debug:
                                s0 = 'call: ' + key + ' depth: ' + `self.call_level` + ' time: ' + `t`
                        if pframe:
-                               pkey = pframe.f_code.co_filename + ':' + \
-                                         `codehack.getlineno(pframe.f_code)` \
-                                         + '(' + \
-                                         codehack.getcodename(pframe.f_code) \
-                                         + ')'
+                               if pframe.f_locals.has_key('__key'):
+                                       pkey = pframe.f_locals['__key']
+                               else:
+                                       pkey = pframe.f_code.co_filename + \
+                                                 ':' + \
+                                                 `codehack.getlineno(pframe.f_code)` \
+                                                 + '(' + \
+                                                 codehack.getcodename(pframe.f_code) \
+                                                 + ')'
+                                       pframe.f_locals['__key'] = pkey
                                if self.debug:
                                        s1 = 'parent: ' + pkey
                                if pframe.f_locals.has_key('__start_time'):
@@ -121,17 +130,25 @@ class Profile:
        def handle_return(self, pframe, frame, s0):
                t = os.times()
                t = t[0] + t[1]
-               funcname = codehack.getcodename(frame.f_code)
-               lineno = codehack.getlineno(frame.f_code)
-               filename = frame.f_code.co_filename
-               key = filename + ':' + `lineno` + '(' + funcname + ')'
-               if self.debug:
-                       s0 = s0 + key + ' depth: ' + `self.call_level` + ' time: ' + `t`
-               if pframe:
+               if frame.f_locals.has_key('__key'):
+                       key = frame.f_locals['__key']
+               else:
                        funcname = codehack.getcodename(frame.f_code)
                        lineno = codehack.getlineno(frame.f_code)
                        filename = frame.f_code.co_filename
-                       pkey = filename + ':' + `lineno` + '(' + funcname + ')'
+                       key = filename + ':' + `lineno` + '(' + funcname + ')'
+                       frame.f_locals['__key'] = key
+               if self.debug:
+                       s0 = s0 + key + ' depth: ' + `self.call_level` + ' time: ' + `t`
+               if pframe:
+                       if pframe.f_locals.has_key('__key'):
+                               pkey = pframe.f_locals['__key']
+                       else:
+                               funcname = codehack.getcodename(frame.f_code)
+                               lineno = codehack.getlineno(frame.f_code)
+                               filename = frame.f_code.co_filename
+                               pkey = filename + ':' + `lineno` + '(' + funcname + ')'
+                               pframe.f_locals['__key'] = pkey
                        if self.debug:
                                s1 = 'parent: '+pkey
                        if pframe.f_locals.has_key('__start_time') and \
index 9bc63421162a42a0c0a4a41bc2efc949d6dd4dfb..393eafd7692da08424dad18ea8fcc5ddc354d48c 100755 (executable)
@@ -46,7 +46,7 @@ def intersect(list):
 # This works with a list or tuple argument.
 #
 def union(list):
-       (left, top), (right, bottom) = empty
+       (left, top), (right, bottom) = list[0]
        for (l, t), (r, b) in list[1:]:
                if not is_empty(((l, t), (r, b))):
                        if l < left: left = l