Currently, we check if hostname is numeric like this (_gai is the original socket.getaddrinfo):
if _ip4(host) or _ip6(host):
return _gai(host, port, family, type, proto, flags)
We could completely remove _ip4 and _ip6 functions and use AI_NUMERICHOST which will reduce the code size by ~10%:
try:
return _gai(host, port, family, type, proto, flags | socket.AI_NUMERICHOST)
except Exception:
pass
This was tested with Python 3 and works fine.
However, AI_NUMERICHOST is currently is not exposed in MicroPython.
It does seem to be available in lwip so we could use it. It requires more testing.
Currently, we check if hostname is numeric like this (
_gaiis the originalsocket.getaddrinfo):We could completely remove
_ip4and_ip6functions and useAI_NUMERICHOSTwhich will reduce the code size by ~10%:This was tested with Python 3 and works fine.
However,
AI_NUMERICHOSTis currently is not exposed in MicroPython.It does seem to be available in
lwipso we could use it. It requires more testing.