Repository navigation
Closed
Description
| BPO | 3959 |
|---|---|
| Nosy | @gvanrossum, @loewis, @gpshead, @abalkin, @pitrou, @giampaolo, @benjaminp, @ezio-melotti, @bitdancer |
| Files |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = 'https://github.com/gpshead'
closed_at = <Date 2009-05-03.07:04:47.318>
created_at = <Date 2008-09-24.23:14:09.742>
labels = []
title = "Add Google's ipaddr.py to the stdlib"
updated_at = <Date 2009-06-02.17:00:27.598>
user = 'https://github.com/gvanrossum'bugs.python.org fields:
activity = <Date 2009-06-02.17:00:27.598>
actor = 'belopolsky'
assignee = 'gregory.p.smith'
closed = True
closed_date = <Date 2009-05-03.07:04:47.318>
closer = 'gregory.p.smith'
components = []
creation = <Date 2008-09-24.23:14:09.742>
creator = 'gvanrossum'
dependencies = []
files = ['13834']
hgrepos = []
issue_num = 3959
keywords = []
message_count = 81.0
messages = ['73761', '73762', '73763', '73764', '73768', '73770', '73793', '74092', '74093', '74094', '78216', '78218', '78666', '78673', '78675', '78677', '78680', '78683', '78700', '78826', '78836', '78908', '78984', '78985', '78988', '78989', '79069', '79098', '79099', '79187', '81006', '81007', '81009', '81010', '81011', '81050', '81141', '81144', '81146', '81147', '81150', '81151', '81167', '82684', '82688', '82695', '84445', '86898', '86902', '86903', '86925', '86926', '86928', '87033', '88653', '88654', '88655', '88672', '88673', '88675', '88676', '88678', '88686', '88688', '88692', '88700', '88703', '88705', '88706', '88707', '88709', '88710', '88711', '88712', '88713', '88717', '88718', '88719', '88720', '88742', '88752']
nosy_count = 16.0
nosy_names = ['gvanrossum', 'loewis', 'gregory.p.smith', 'belopolsky', 'Rhamphoryncus', 'pitrou', 'giampaolo.rodola', 'benjamin.peterson', 'ezio.melotti', 'mattsmart', 'shields', 'pmoody', 'pnasrat', 'r.david.murray', 'oubiwann', 'claymation']
pr_nums = []
priority = 'normal'
resolution = 'accepted'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue3959'
versions = ['Python 3.1']Metadata
Metadata
Assignees
Labels
No labels
Activity
gvanrossum commentedon Sep 24, 2008
Google just released ipaddr.py, a module that knows how to manipulate IP
addresses (both IPv4 and IPv6).
I have nothing to do with this module, but I suggest considering it for
inclusion in the standard library.
It fills a gap for address manipulations that will become more important
to fill as IPv6 becomes more widespread.
benjaminp commentedon Sep 24, 2008
Where can we find this?
gvanrossum commentedon Sep 24, 2008
It would help if I added a link to the Google release:
http://code.google.com/p/ipaddr-py/
Description:
"
An IPv4/IPv6 manipulation library in Python.
This library is used to create/poke/manipulate IPv4 and IPv6 addresses
and prefixes.
"
benjaminp commentedon Sep 24, 2008
Almost time machine. :)
loewis commentedon Sep 25, 2008
I see a list of owners in the code (although it's difficult to infer
real names or email addresses from that list). I think we should not
include the code without their explicit approval.
The question will then always be: what is the official master copy of
the code? The one in Python, or the one on Google code? Whose
responsibility would it be to keep those synchronized, and incorporate
changes from one copy into the other?
I would prefer if the copy in Python (say, 2.7) becomes the master copy,
and the copy on Google code eventually disappears (when interest in
older Python versions has died).
I would object to a mere fork of the code (i.e. where one of the regular
Python committers incorporates, from time to time, the changes that
Google made)
pmoody commentedon Sep 25, 2008
as one of the owners listed in the code.google.com project (same name),
and the original author, you certainly have my approval for inclusion in
python.
gvanrossum commentedon Sep 25, 2008
On Wed, Sep 24, 2008 at 9:07 PM, Martin v. Löwis <[email protected]> wrote:
I know they *want* this to happen, no worries on this front.
I'm in favor of this, and I believe the authors at Google are too --
it was written out of necessity, and once integrated, the need for a
separate Google copy will go away.
Agreed.
vstinner commentedon Sep 30, 2008
I'm the maintainer of IPy library. Another library for IPv4/IPv6
manipulation. The code is old (was written for Python 2.2?), but
released under BSD license. Main issue of this library: it's unable to
manipulation "invalid ranges": 10.20.4.0/30 is valid but
10.20.4.1-10.20.4.5 is invalid since it's not possible to create a
bitmask matching the range. I don't care if you choose Google library,
maybe better. But you might check IPy to reuse some idea ;-)
vstinner commentedon Sep 30, 2008
Ooops, the website: http://software.inl.fr/trac/wiki/IPy
vstinner commentedon Sep 30, 2008
Another Python library: http://erlug.linux.it/~da/soft/iplib/
benjaminp commentedon Dec 22, 2008
Now that 2.6 and 3.0 are out of the way, how should we move forward?
Will a PEP be required?
loewis commentedon Dec 22, 2008
I think some committer needs to take charge and work with the authors
on merging the code. If pmoody wants commit access, that should be set
up, and he should add it himself in a commit-after-review manner (with
an actual patch, including documentation and tests).
If he doesn't want to do the integration, some committer needs to
volunteer - I personally won't (lack of time).
In any case, we would need a copyright form signed, unless Guido can
confirm that the code is covered by some agreement between Google and
the PSF.
I doubt that; a quick announcement to python-dev might be sufficient
(in general, a PEP should only be done if dissent is likely). It
seems that Victor didn't actually disagree to integrating this
package; we should somehow encourage IPy users to review the code
and comment on the (possibly lack of) functionality.
drkjam commentedon Dec 31, 2008
I think this might be worth a look before any hard and fast decisions
are made :-
http://code.google.com/p/netaddr/
pmoody commentedon Jan 1, 2009
I'm biased ;) but I don't see what netaddr provides over ipaddr. it
also seems to be in the neighborhood of 50% slower (at least on my mac
mini).
pmoody@mini - 04:52 PM - ~/Downloads/ipaddr-1.0.1
-> python -m timeit 'import ipaddr;\
ipaddr.IP("1.1.1.1")'
10000 loops, best of 3: 46.2 usec per loop
pmoody@mini - 04:52 PM - ~/Downloads/netaddr-0.5.2
-> python -m timeit 'import netaddr;\
netaddr.IP("1.1.1.1")'
10000 loops, best of 3: 71.9 usec per loop
dealing with netmasks, the difference is even greater.
pmoody@mini - 04:52 PM - ~/Downloads/ipaddr-1.0.1
-> python -m timeit 'import ipaddr;\
ipaddr.IP("1.1.1.1/255.255.255.0")'
10000 loops, best of 3: 78.4 usec per loop
pmoody@mini - 04:49 PM - ~/Downloads/netaddr-0.5.2
-> python -m timeit 'import netaddr;\
(and it doesn't seem to deal with hostsmasked addresses).
it also seems to be layed out in an unintuitive way, treating address
ranges a something very different than network addresses. hopefully
someone who isn't intimately familiar with both libraries can comment,
but ipaddr feels a lot cleaner to me.
exarkun commentedon Jan 1, 2009
Performance shouldn't be a major concern here. Utility is more
important and the implementation can be optimized later.
My initial impression of netaddr is pretty good. One thing it has going
for it is documentation. The netaddr google page gives a really great
overview of the functionality provided. In comparison, the ipaddr-py
page is extremely sparse; the documentation in the repository is no
better (as there isn't really any).
There are a lot of minor things about ipaddr-py which are off-putting.
It uses a naming convention that's not like any real Python software I'm
familiar with. In particular, CamelCase method names really draw the
eye (in a bad way) and distract from the actual functionality being
provided. I assume that if ipaddr-py is selected for inclusion, the API
will be adapted to fit PEP-8. In comparison, netaddr appears to largely
comply with PEP-8 already.
Regarding the treatment of addresses versus address ranges, I prefer
netaddr's solution. An address is not the same as an address range. It
seems odd to try to represent them both with the same type as ipaddr-py
does. This feels somewhat APLesque (where everything is a vector),
which isn't bad in itself, but generally if I want to manipulate an IP
address, I'm not thinking about it as a list of one address. If I
wanted to do that, then I'd make a list and put the address in it. By
comparison, the separate CIDR type in netaddr makes a lot of sense. It
preserves a memory-efficient representation of the address range, but
does it with a different type than the fundamental address type.
This is far from a complete review of either library, obviously. I've
done little more than glance over the documentation of each and do a
small amount of interactive playing around. A lot more effort seems to
have gone into making netaddr accessible and appealing, and I think it
has succeeded. Perhaps if some documentation for ipaddr-py is written
it will be easier to see where that library excels. Of course, I assume
this is a prerequisite for inclusion in the standard library as well.
56 remaining items
claymation commentedon Jun 2, 2009
On Mon, Jun 1, 2009 at 4:51 PM, pmoody <[email protected]> wrote:
Fortunately, it's not up for debate: RFC-791 defines an IP address as
a 32-bit number, with no provision for a mask. Networks are defined by
their address and their mask. To correctly model them in an
object-oriented system, we would say that a Network has-a Address,
certainly not that a Network is-a Address.
I will go ahead and open issues on code.google.com.
I'd like to hear from application developers outside of Google. The
two that have commented on this issue seem not to prefer ipaddr's API.
Clay
claymation commentedon Jun 2, 2009
On Mon, Jun 1, 2009 at 7:51 PM, pmoody <[email protected]> wrote:
The example demonstrates one case where the strings '192.168.1.1' and
'192.168.1.1/32' are not equivalent -- it wouldn't be hard to find
other examples -- yet you seem to think that (a) this is
Darwin-specific behavior, and that (b) this discrepancy is acceptable
and does not constitute a design flaw.
You're wrong on both fronts, since in fact all IP implementations
understand classful addressing (as per RFC-791), not just Darwin, and
your insistence on the equality of '192.168.1.1' and '192.168.1.1/32'
means that your library is unusable in applications that pass
ipaddr.IPv4 objects to ifconfig.
Clay
claymation commentedon Jun 2, 2009
On Mon, Jun 1, 2009 at 8:05 PM, R. David Murray <[email protected]> wrote:
Sorry, but why should you determine what is better for my application?
Again, you're wrong. The mask that you see in ifconfig is associated
with the network to which the interface is attached, not the interface
address. You also see a broadcast address in the ifconfig output, but
certainly you don't believe that the broadcast address is a property
of the interface address? No, of course not; it's a property of the
network to which the interface is attached -- just like the mask.
That's why we call it a "netmask".
Host routes are routes like all others -- they have a destination
address and a mask. That a host route has a prefix length of 32 does
not imply that the host route is equivalent to the host address.
You're confusing the two concepts.
By "ip/hostmask" pair, you actually mean "ip/netmask" pair, and yes,
this is a convenient notation for expressing two distinct but related
concepts: an address, and a mask. Addresses do not have masks;
networks do. I am not sure how to be any more clear about that point,
yet you still seem not to understand.
I'm not advocating classful routing, I'm merely stating (emphatically
and without ambiguity) that addresses and networks are different:
networks have masks; addresses do not. The ipaddr library forces a
mask on me every time I specify an address. In my view, that is a
design flaw.
Clay
claymation commentedon Jun 2, 2009
On Mon, Jun 1, 2009 at 9:03 PM, pmoody <[email protected]> wrote:
Let's say I have a UI that prompts users for two pieces of
information: interface address, and network mask. I then take those
two strings and make ipaddr.IPv4 objects out of them. This lets me
validate their correctness, and lets me perform convenient
calculations and tests (things the ipaddr library has done well).
Next, I take the IPv4 objects, coerce them to strings, and pass them
to ifconfig to configure an interface.
Assuming the user has supplied this information:
Interface address = '192.168.1.1'
Network mask = '255.255.255.0'
the following would get passed to ifconfig:
ifconfig en0 192.168.1.1/32 netmask 255.255.255.0/32
Clearly this is not what we expect, nor even legal. The principle of
least surprise is violated here, if nothing else.
We could work around this, of course, but why should we have to work
around our libraries when simply fixing them isn't that hard?
Your definition of onerous apparently differs from mine :)
In my own applications, when I'm expecting a network, I use an
IPNetwork class, and when I'm expecting an address, I use an IPAddress
class. This means I can simply rely on the class constructors to do
the type checking for me. With ipaddr, I have to do the validation
myself. Simple isinstance() testing and duck typing don't work because
networks and addresses are represented (wrongly) by the same class.
Rest assured, I've opened one issue and will open one or two more
before the night is out.
I'm sorry that you think "yelling" is unproductive. I happen to think
that healthy debate breeds better code.
Cheers,
Clay
pmoody commentedon Jun 2, 2009
I suppose that might be the case if you didn't know how to use ipaddr.
knowing that ipaddr accepts an ipaddress/netmask, I'd pass it
and then check for any exceptions. I'd then ifconfig en0 str(my_ip)
so ipaddr doing this validation for the user actually could make some
sense, but this could be fixed by something as easy
anyway (more below)...
cool, I see that you did that. as an aside, this probably isn't the
best place for continued discussion on ipaddr. ipaddr has already been
shipped with python, so i'm not sure that debate on it's inclusion is
able to influence that decision. All of the folks who've worked on
ipaddr + the python committer are on [email protected]
(looks like you are too), so might I suggest we continue this
discussion there?
I think debate is healthy, too. but I measure my success at a debate
by my ability to convince other people of my side. I find I have
better success when I listen other people and respond with respect.
yelling promotes neither of those.
Cheers,
/peter
loewis commentedon Jun 2, 2009
If that is a frequent need, it would be reasonable to add an API
which would raise an exception if a mask was specified (as an
old-style bit mask, or in CIDR form).
With the current API, you don't need to write it in such a quirky
way. Instead
would do as well.
Well, you deliberately make it appear more quirky than it actually is.
loewis commentedon Jun 2, 2009
If you want to see them fixed in Python, please report them to this
tracker.
claymation commentedon Jun 2, 2009
On Tue, Jun 2, 2009 at 1:21 AM, Martin v. Löwis <[email protected]> wrote:
I'd like to see the issues fixed upstream, and the library removed
from Python until it is satisfactory to the developers who will
actually use it. To my knowledge, every developer (outside of Google)
who has commented on the issue has indicated a preference for a
different API.
Thanks,
Clay
gpshead commentedon Jun 2, 2009
Support for this can be added (its too late for Python 3.1). User
input validation is a good use case. For now I suggest the simpler
code:
Or for a more pedantic test prior to calling ipaddr.IP.
Please file a feature request on bugs.python.org for this one if you
haven't already. We could add optional parameter(s) to ipaddr.IP to
enable only accepting host addresses or network addresses in the
future.
loewis commentedon Jun 2, 2009
That's not true - I'm outside of Google, and have not indicated such
a preference.
claymation commentedon Jun 2, 2009
On Tue, Jun 2, 2009 at 2:18 AM, Martin v. Löwis <[email protected]> wrote:
You've indicated no preference either way, and have said:
"I personally have no plans for using this library, or any other IP
address library"
I should think you would seek the opinion of those developers who
actually do have plans to use an IP address library. As far as I can
tell, every developer in that category, outside of Google, that has
commented on this issue here or in python-dev has advocated a
different API.
Clay
pmoody commentedon Jun 2, 2009
That's what this has been doing for the last 8 1/2 months.
Is there some sort of conspiracy theory-ish reason that a google
software engineer might be somehow unfairly influenced?
Cheers,
/peter
claymation commentedon Jun 2, 2009
On Tue, Jun 2, 2009 at 2:52 AM, pmoody <[email protected]> wrote:
From reading your comments and the code, it is clear that concepts
that aren't relevant at Google have been neglected. For that reason,
developers at Google who are already familiar with ipaddr might
consider its API quite natural because of their institutionalized
thinking. But since this library is now intended for general purpose
use outside Google, I should think it is important to consult
developers outside Google who have been exposed to a broader range of
IP addressing issues. I don't believe that "good enough for Google"
ought to be our acid test.
The fact that developers outside Google seem to prefer a different API
is not new -- comments in this issue dating back several months
reflect that fact. What I don't see is a comment that explains why
their concerns were not considered.
Clay
gpshead commentedon Jun 2, 2009
This issue is closed.
Please take discussion up on a mailing list.