Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4fddf33

Browse files
XEvent.py: Added support for ExposeEvent.
profile.py: Some speed improvements (I hope). rect.py: Bug fix in union().
1 parent f64992e commit 4fddf33

3 files changed

Lines changed: 35 additions & 18 deletions

File tree

Lib/lib-stdwin/rect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def intersect(list):
4646
# This works with a list or tuple argument.
4747
#
4848
def union(list):
49-
(left, top), (right, bottom) = empty
49+
(left, top), (right, bottom) = list[0]
5050
for (l, t), (r, b) in list[1:]:
5151
if not is_empty(((l, t), (r, b))):
5252
if l < left: left = l

Lib/profile.py

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,29 @@ def trace_dispatch(self, frame, event, arg):
3636
self.profiling = 1
3737
t = os.times()
3838
t = t[0] + t[1]
39-
lineno = codehack.getlineno(frame.f_code)
40-
filename = frame.f_code.co_filename
41-
key = filename + ':' + `lineno` + '(' + funcname + ')'
39+
if frame.f_locals.has_key('__key'):
40+
key = frame.f_locals['__key']
41+
else:
42+
lineno = codehack.getlineno(frame.f_code)
43+
filename = frame.f_code.co_filename
44+
key = filename + ':' + `lineno` + '(' + funcname + ')'
45+
frame.f_locals['__key'] = key
4246
self.call_level = depth(frame)
4347
self.cur_frame = frame
4448
pframe = frame.f_back
4549
if self.debug:
4650
s0 = 'call: ' + key + ' depth: ' + `self.call_level` + ' time: ' + `t`
4751
if pframe:
48-
pkey = pframe.f_code.co_filename + ':' + \
49-
`codehack.getlineno(pframe.f_code)` \
50-
+ '(' + \
51-
codehack.getcodename(pframe.f_code) \
52-
+ ')'
52+
if pframe.f_locals.has_key('__key'):
53+
pkey = pframe.f_locals['__key']
54+
else:
55+
pkey = pframe.f_code.co_filename + \
56+
':' + \
57+
`codehack.getlineno(pframe.f_code)` \
58+
+ '(' + \
59+
codehack.getcodename(pframe.f_code) \
60+
+ ')'
61+
pframe.f_locals['__key'] = pkey
5362
if self.debug:
5463
s1 = 'parent: ' + pkey
5564
if pframe.f_locals.has_key('__start_time'):
@@ -121,17 +130,25 @@ def trace_dispatch(self, frame, event, arg):
121130
def handle_return(self, pframe, frame, s0):
122131
t = os.times()
123132
t = t[0] + t[1]
124-
funcname = codehack.getcodename(frame.f_code)
125-
lineno = codehack.getlineno(frame.f_code)
126-
filename = frame.f_code.co_filename
127-
key = filename + ':' + `lineno` + '(' + funcname + ')'
128-
if self.debug:
129-
s0 = s0 + key + ' depth: ' + `self.call_level` + ' time: ' + `t`
130-
if pframe:
133+
if frame.f_locals.has_key('__key'):
134+
key = frame.f_locals['__key']
135+
else:
131136
funcname = codehack.getcodename(frame.f_code)
132137
lineno = codehack.getlineno(frame.f_code)
133138
filename = frame.f_code.co_filename
134-
pkey = filename + ':' + `lineno` + '(' + funcname + ')'
139+
key = filename + ':' + `lineno` + '(' + funcname + ')'
140+
frame.f_locals['__key'] = key
141+
if self.debug:
142+
s0 = s0 + key + ' depth: ' + `self.call_level` + ' time: ' + `t`
143+
if pframe:
144+
if pframe.f_locals.has_key('__key'):
145+
pkey = pframe.f_locals['__key']
146+
else:
147+
funcname = codehack.getcodename(frame.f_code)
148+
lineno = codehack.getlineno(frame.f_code)
149+
filename = frame.f_code.co_filename
150+
pkey = filename + ':' + `lineno` + '(' + funcname + ')'
151+
pframe.f_locals['__key'] = pkey
135152
if self.debug:
136153
s1 = 'parent: '+pkey
137154
if pframe.f_locals.has_key('__start_time') and \

Lib/stdwin/rect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def intersect(list):
4646
# This works with a list or tuple argument.
4747
#
4848
def union(list):
49-
(left, top), (right, bottom) = empty
49+
(left, top), (right, bottom) = list[0]
5050
for (l, t), (r, b) in list[1:]:
5151
if not is_empty(((l, t), (r, b))):
5252
if l < left: left = l

0 commit comments

Comments
 (0)