urllib slow on FreeBSD 4.7? sockets too

Mike Brown mike at skew.org
Sat Nov 23 06:04:41 EST 2002


"Jarkko Torppa" <torppa at staff.megabaud.fi> wrote:
[...]
> u = urllib.urlopen('http://localhost/4m')
> fn = u.fp.fileno()
> bytea = [ ]
> while 1:
>     bytes = os.read(fn, 16 * 1024)

[...]

Thought I'd try this on Windows, too. Interestingly, os.read() on Windows
does not like fn...
OSError: [Errno 9] Bad file descriptor

Using the byte array approach with u.read(16 * 1024) in chunks yields about
8.4 MB/s, where as just using u.read() yields about 6.5 MB/s. This is as
compared to the ~12 MB/s on the raw socket I/O.





More information about the Python-list mailing list