|
|
|
|
|
by marvy
3576 days ago
|
|
You could, but then it's not quite so quick-and-dirty anymore :) The de-queue method goes from "self.i += 1" (Python syntax) to self.i +=1
if self.i > len(self.a)/2:
self.a[:self.i] = []
self.i = 0
I didn't test the above code, and I am only 50% sure it is bug-free. I'm 99% sure the leaky version is bug-free. Memory leaks are not a bug if I document them, right? ;)But yes, periodically deleting the wasted space is still easier than trying to do the usual thing with circular buffers and stuff :) |
|