diff --git a/direct/src/heapq/Sources.pp b/direct/src/heapq/Sources.pp index 4fed938602..8710a0d160 100755 --- a/direct/src/heapq/Sources.pp +++ b/direct/src/heapq/Sources.pp @@ -5,8 +5,6 @@ // under Windows). #define DIR_TYPE metalib -//#define BUILDING_DLL BUILDING_DIRECT - #define OTHER_LIBS \ pandaexpress:m \ diff --git a/direct/src/heapq/heapq.cxx b/direct/src/heapq/heapq.cxx index 7a133e4ccc..b25f0593d4 100755 --- a/direct/src/heapq/heapq.cxx +++ b/direct/src/heapq/heapq.cxx @@ -4,6 +4,9 @@ reported to be about 20x faster. In 2.4 they reimplemented heapq in C so it should be comparable to this. At this time though, Python 2.4 is still in alpha. + + Note: This code has been bastardized to only work on Tasks temporarily. + */ #include @@ -122,7 +125,7 @@ heapify(PyObject *self, PyObject *args) { static int _siftdown(PyObject *list, int startpos, int pos) { PyObject *newitem, *parent; - int parentpos, cmp; + int parentpos; newitem = PySequence_GetItem(list,pos); @@ -150,11 +153,8 @@ _siftdown(PyObject *list, int startpos, int pos) { if (parentCTask->get_wake_time() <= newitemCTask->get_wake_time()) { break; - } else { - return -1; } - Py_INCREF(parent); PyList_SetItem(list,pos,parent); pos = parentpos; @@ -168,7 +168,6 @@ _siftup(PyObject *list, int pos) { PyObject *newitem, *right, *child; int endpos, rightpos, childpos; int startpos = pos; - int cmp; endpos = PyList_Size(list); newitem = PySequence_GetItem(list,pos); @@ -202,8 +201,6 @@ _siftup(PyObject *list, int pos) { if (rightCTask->get_wake_time() <= childCTask->get_wake_time()) { childpos = rightpos; - } else { - return -1; } } child = PySequence_GetItem(list,childpos); diff --git a/direct/src/task/Task.py b/direct/src/task/Task.py index df6c78373c..1914327c6b 100644 --- a/direct/src/task/Task.py +++ b/direct/src/task/Task.py @@ -86,28 +86,28 @@ class Task(CTask): self.pstats = None self.extraArgs = None - # Used for putting into the doLaterList - # the heapq calls __cmp__ via the rich compare function - def __cmp__(self, other): - if isinstance(other, Task): - if self.getWakeTime() < other.getWakeTime(): - return -1 - elif self.getWakeTime() > other.getWakeTime(): - return 1 - # If the wakeTimes happen to be the same, just - # sort them based on id - else: - return cmp(id(self), id(other)) - # This is important for people doing a (task != None) and such. - else: - return cmp(id(self), id(other)) +# # Used for putting into the doLaterList +# # the heapq calls __cmp__ via the rich compare function +# def __cmp__(self, other): +# if isinstance(other, Task): +# if self.getWakeTime() < other.getWakeTime(): +# return -1 +# elif self.getWakeTime() > other.getWakeTime(): +# return 1 +# # If the wakeTimes happen to be the same, just +# # sort them based on id +# else: +# return cmp(id(self), id(other)) +# # This is important for people doing a (task != None) and such. +# else: +# return cmp(id(self), id(other)) - # According to the Python manual (3.3.1), if you define a cmp operator - # you should also define a hash operator or your objects will not be - # usable in dictionaries. Since no two task objects are unique, we can - # just return the unique id. - def __hash__(self): - return self.id +# # According to the Python manual (3.3.1), if you define a cmp operator +# # you should also define a hash operator or your objects will not be +# # usable in dictionaries. Since no two task objects are unique, we can +# # just return the unique id. +# def __hash__(self): +# return self.id def remove(self): if not self.__removed: