While looking at the source code of the asyncore module I came across this method. I'll include it here without context, as it seems to be quite self contained:
def initiate_send(self):
num_sent = 0
num_sent = dispatcher.send(self, self.out_buffer[:512])
self.out_buffer = self.out_buffer[num_sent:]
My question: Why is num_sent
first set to 0
, but then immediately set again to another value?
If i'd found this anywhere but in the python source code, I'd say that this line of code is superfluous. Is there any point to it, or is it dead code?
That's dead code; it's a local variable, so it is not ever going to influence anything else.
If it had been a instance variable, then dispatcher.send
could have read the value while executing, but it's completely superfluous here.
The asyncore
module is relatively ancient, the line has been there since it was first committed to the python codebase in 1999.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With