Jack Jansen wrote: > Could the defenders of Stackless Python please explain _why_ this > is such a great idea? Just and Christian seem to swear by it, but > I'd like to hear of some simple examples of programming tasks > that will be programmable in 50% less code with it (or 50% more > understandable code, for that matter). Here's the complete code for the download of a file (the data connection of an FTP server): def _doDnStream(self, binary=0): mode = 'r' if binary: mode = mode + 'b' f = open(self.cmdconn.filename, mode) if self.cmdconn.filepos: #XXX check length of file f.seek(self.cmdconn.filepos, 0) while 1: if self.abort: break data = f.read(8192) sz = len(data) if sz: if not binary: data = '\r\n'.join(data.split('\n')) self.write(data) if sz < 8192: break [from the base class] def write(self, msg): while msg: sent = self.dispatcher.write(self.sock, msg) if sent == 0: raise IOError, "unexpected EOF" msg = msg[sent:] Looks like blocking sockets, right? Wrong. That's a fully multiplexed socket. About a dozen lines of code (hidden in that dispatcher object) mean that I can write async without using a state machine. stackless-forever-ly y'rs - Gordon
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4