timeit and __future__

2009-06-19 Thread Karl Chen
I wanted to time something that uses with_statement, in python2.5. Importing __future__ in the statement or the setup doesn't work since it's not the beginning of the code being compiled. Other than using a separate module, I could only come up with this: timeit.template = 'from __future__ i

socket.getaddrinfo: flags |= AI_ADDRCONFIG

2008-11-05 Thread Karl Chen
I've discovered that since glibc 2.3.2, getaddrinfo(3) supports a useful flag called AI_ADDRCONFIG. It turns off lookups if the machine isn't configured for IPv6 (and similarly for IPv4, theoretically). This is especially important when behind gateways whose DNS forwarder silently filter AA