Mar-09-2020, 03:10 AM
I reduced the cpu usage of my program by more than half by using select.poll rather than the Pipe's own poll routine:
in __init__
Where is the actual implementation? So why would this be so slow?
in __init__
... self.pollin = select.poll() self.pollin.register(self.pipe, select.POLLIN) ... def readline(self): # if self.pipe.poll(): # pipe poll is really slow!!!!! better use our own if self.pollin.poll(0): return self.pipe.recv() return FalseI measured the time from before and after calling pipe.poll and it's more than 10 times slower than using the select poll routine but does exactly the same thing from what I can tell except I have to pass 0 to avoid blocking.
Where is the actual implementation? So why would this be so slow?