[Python-Dev] _socket efficiencies ideas

"Martin v. L÷wis" martin@v.loewis.de
Wed, 09 Apr 2003 20:36:17 +0200


Sean Reifschneider wrote:

> My first thought is that there should be a local DNS cache on the
> machine that is running these apps.  My second thought is that Python
> could benefit from caching some lookup information...

I disagree. Python should expose the resolver library, and leave caching
to it; many such libraries do caching already, in some form.

The issue is different: In some cases the application just *knows* that
an address is numeric, and that DNS lookup will fail. In these cases,
lookup should be avoided - whether by explicit request from the 
application or by Python implicitly just knowing is a different issue.

It turns out that Python doesn't need to 100% detect numeric addresses,
as long as it would not classify addresses as numeric which aren't. 
Perhaps it is even possible to leave the "is numeric" test to the 
implementation of getaddrinfo, i.e. calling it twice (try numeric first, 
then try resolving the name)?

Regards,
Martin