gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow)

anntzer.lee at gmail.com anntzer.lee at gmail.com
Mon Sep 2 01:28:21 EDT 2013


On Sunday, September 1, 2013 2:03:56 PM UTC-7, Chris Angelico wrote:

> > I tried using netifaces (https://pypi.python.org/pypi/netifaces) which seems to rely on getifaddrs (according to the doc, I didn't check the source).  Again, it returns nearly instantaneously the correct IP address.
> 
> Perfect!
> 
> ChrisA

Not really for my use case -- it isn't that *I* want to know my public IP address, but rather that IPython wants to know it.  Of course I could patch IPython's source to use netifaces but that sounds like an overkill.

As it happens I found a better way: just add the proper entry to /etc/hosts.

Still, thanks for the suggestions.

Antony



More information about the Python-list mailing list