[Web-SIG] Re: Bill's comments on WSGI draft 1.4
Phillip J. Eby
pje at telecommunity.com
Mon Sep 6 20:14:31 CEST 2004
At 09:44 AM 9/6/04 -0700, tony at lownds.com wrote:
>But using a file object as an iterable is going to give terrible
>performance, and fileno() isn't good enough for Jython and IronPython. I
>don't see why allowing a file-like object is unreasonable.
Because explicit is better than implicit. Returning a "file-like" object
can mean, "read all the data and send it as one block", or "read the data
in arbitrary-size blocks and send them". The application should say what
it means! Either:
return [filelike.read()]
or:
yield filelike.read()
or:
return iter(lambda: filelike.read(bufsize), '')
or something else, according to the results it intends. The server
shouldn't have to *guess* which of these is meant.
More information about the Web-SIG
mailing list