Are you sure that there is no standard implementation of this in netaddr?