[Python-Dev] PEP 3144 review.

Daniel Stutzbach daniel at stutzbachenterprises.com
Wed Sep 30 23:59:56 CEST 2009


.On Wed, Sep 30, 2009 at 3:33 PM, R. David Murray <rdmurray at bitdance.com>wrote:

>    1) do not add another class, just pass around (IPvXAddress,
>    IPVXNetwork) tuples when the address needs to be retained (or write
>    your own tailored trivial class, like I did in my example).
>

I've been puzzled by objections to forcing the user to decide what metadata
to store.  Every time I've ever needed to store an IP address or a network,
I've always need to store a bunch of other affiliated data with it.  E.g.:

class GnutellaPeer:
    # IP address, port, timestamp, and dozen of other fields

class NetworkInterface:
   # IP address, subnet mask, name, MAC address, etc.

class Route:
   # interface, IP address, subnet mask, gateway address, route priority

Is it such a burden for the programmer to store one extra field in the class
they will inevitably write?

For that matter, I do not see the advantage to an IPNetwork class that saves
the programmer from having to separately store the IP address and subnet
mask.  Maybe I am biased by my background: I learned network programming in
C, and I think of an IP address as little more than an integer type with a
special string representation.

People have voiced support for the IPNetwork class and for the occasional
utility of an .ip field.  I assume they have good use cases.  It would be
nice if the use cases were collected into the PEP, in a clear and articulate
way.  Preferably by someone other than ipaddr author, for whom the use cases
are understandably a bit too obvious to explain at length with
exasperation.  It aught to be easy to justify the functionality of the
library, if the use cases are clearly articulated.

The current PEP begins by noting that many other IP address libraries are
available, but doesn't describe what makes ipaddr unique or superior other
than a claim to being lightweight.  After downloading several of the other
IP address libraries (http://bit.ly/483Yw4), ipaddr appears to be the second
largest, after the huge netaddr package.<http://packages.python.org/netaddr/>
I worry that this discussion has focused too much on the details of ipaddr
(and the false dichotomy of "ipaddr versus nothing"), without properly
tackling the question of "What use-cases for IP addresses are sufficiently
universal* that they belong in the standard library?"

--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20090930/f316be3e/attachment.htm>


More information about the Python-Dev mailing list