mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
XEvent.py: Added support for ExposeEvent.
profile.py: Some speed improvements (I hope). rect.py: Bug fix in union().
This commit is contained in:
parent
f64992e95d
commit
4fddf33c87
3 changed files with 35 additions and 18 deletions
|
@ -46,7 +46,7 @@ def intersect(list):
|
||||||
# This works with a list or tuple argument.
|
# This works with a list or tuple argument.
|
||||||
#
|
#
|
||||||
def union(list):
|
def union(list):
|
||||||
(left, top), (right, bottom) = empty
|
(left, top), (right, bottom) = list[0]
|
||||||
for (l, t), (r, b) in list[1:]:
|
for (l, t), (r, b) in list[1:]:
|
||||||
if not is_empty(((l, t), (r, b))):
|
if not is_empty(((l, t), (r, b))):
|
||||||
if l < left: left = l
|
if l < left: left = l
|
||||||
|
|
|
@ -36,20 +36,29 @@ class Profile:
|
||||||
self.profiling = 1
|
self.profiling = 1
|
||||||
t = os.times()
|
t = os.times()
|
||||||
t = t[0] + t[1]
|
t = t[0] + t[1]
|
||||||
lineno = codehack.getlineno(frame.f_code)
|
if frame.f_locals.has_key('__key'):
|
||||||
filename = frame.f_code.co_filename
|
key = frame.f_locals['__key']
|
||||||
key = filename + ':' + `lineno` + '(' + funcname + ')'
|
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.call_level = depth(frame)
|
||||||
self.cur_frame = frame
|
self.cur_frame = frame
|
||||||
pframe = frame.f_back
|
pframe = frame.f_back
|
||||||
if self.debug:
|
if self.debug:
|
||||||
s0 = 'call: ' + key + ' depth: ' + `self.call_level` + ' time: ' + `t`
|
s0 = 'call: ' + key + ' depth: ' + `self.call_level` + ' time: ' + `t`
|
||||||
if pframe:
|
if pframe:
|
||||||
pkey = pframe.f_code.co_filename + ':' + \
|
if pframe.f_locals.has_key('__key'):
|
||||||
`codehack.getlineno(pframe.f_code)` \
|
pkey = pframe.f_locals['__key']
|
||||||
+ '(' + \
|
else:
|
||||||
codehack.getcodename(pframe.f_code) \
|
pkey = pframe.f_code.co_filename + \
|
||||||
+ ')'
|
':' + \
|
||||||
|
`codehack.getlineno(pframe.f_code)` \
|
||||||
|
+ '(' + \
|
||||||
|
codehack.getcodename(pframe.f_code) \
|
||||||
|
+ ')'
|
||||||
|
pframe.f_locals['__key'] = pkey
|
||||||
if self.debug:
|
if self.debug:
|
||||||
s1 = 'parent: ' + pkey
|
s1 = 'parent: ' + pkey
|
||||||
if pframe.f_locals.has_key('__start_time'):
|
if pframe.f_locals.has_key('__start_time'):
|
||||||
|
@ -121,17 +130,25 @@ class Profile:
|
||||||
def handle_return(self, pframe, frame, s0):
|
def handle_return(self, pframe, frame, s0):
|
||||||
t = os.times()
|
t = os.times()
|
||||||
t = t[0] + t[1]
|
t = t[0] + t[1]
|
||||||
funcname = codehack.getcodename(frame.f_code)
|
if frame.f_locals.has_key('__key'):
|
||||||
lineno = codehack.getlineno(frame.f_code)
|
key = frame.f_locals['__key']
|
||||||
filename = frame.f_code.co_filename
|
else:
|
||||||
key = filename + ':' + `lineno` + '(' + funcname + ')'
|
|
||||||
if self.debug:
|
|
||||||
s0 = s0 + key + ' depth: ' + `self.call_level` + ' time: ' + `t`
|
|
||||||
if pframe:
|
|
||||||
funcname = codehack.getcodename(frame.f_code)
|
funcname = codehack.getcodename(frame.f_code)
|
||||||
lineno = codehack.getlineno(frame.f_code)
|
lineno = codehack.getlineno(frame.f_code)
|
||||||
filename = frame.f_code.co_filename
|
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:
|
if self.debug:
|
||||||
s1 = 'parent: '+pkey
|
s1 = 'parent: '+pkey
|
||||||
if pframe.f_locals.has_key('__start_time') and \
|
if pframe.f_locals.has_key('__start_time') and \
|
||||||
|
|
|
@ -46,7 +46,7 @@ def intersect(list):
|
||||||
# This works with a list or tuple argument.
|
# This works with a list or tuple argument.
|
||||||
#
|
#
|
||||||
def union(list):
|
def union(list):
|
||||||
(left, top), (right, bottom) = empty
|
(left, top), (right, bottom) = list[0]
|
||||||
for (l, t), (r, b) in list[1:]:
|
for (l, t), (r, b) in list[1:]:
|
||||||
if not is_empty(((l, t), (r, b))):
|
if not is_empty(((l, t), (r, b))):
|
||||||
if l < left: left = l
|
if l < left: left = l
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue