mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
Added a _v21 def to FL.py and added two new input field types
Added runcall(func, *args) interfaces to profile.py, bdb.py, pdb.py, wdb.py Added new module bisect.py and used it in sched.py. Mostly cosmetic changes to profile.py (changed output format).
This commit is contained in:
parent
2179945eec
commit
4e16098ce7
9 changed files with 167 additions and 160 deletions
13
Lib/sched.py
13
Lib/sched.py
|
@ -28,6 +28,8 @@
|
|||
# XXX instead of having to define a module or class just to hold
|
||||
# XXX the global state of your particular time and delay functtions.
|
||||
|
||||
import bisect
|
||||
|
||||
class scheduler:
|
||||
#
|
||||
# Initialize a new instance, passing the time and delay functions
|
||||
|
@ -43,16 +45,7 @@ class scheduler:
|
|||
# to remove it, if necessary.
|
||||
#
|
||||
def enterabs(self, event):
|
||||
time, priority, action, argument = event
|
||||
q = self.queue
|
||||
# XXX Could use bisection or linear interpolation?
|
||||
for i in range(len(q)):
|
||||
qtime, qpri, qact, qarg = q[i]
|
||||
if time < qtime: break
|
||||
if time == qtime and priority < qpri: break
|
||||
else:
|
||||
i = len(q)
|
||||
q.insert(i, event)
|
||||
bisect.insort(self.queue, event)
|
||||
return event # The ID
|
||||
#
|
||||
# A variant that specifies the time as a relative time.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue