[Python-Dev] PEP 3144 review.
jonrascal at gmail.com
Wed Sep 16 04:49:38 CEST 2009
I'd like to see more clear direction for this. Is it a string manipulation
library, or an IP address library?
There are ONLY TWO types of IP representations:
1. Network = 32 bit number AND 32 bit mask. That is the binary AND. The mask
needs to be preserved, but not the network portion. Any library should
return the ANDed result. Whether the number is 18.104.22.168/24 or
192.168.1.0/24, the result after 'and' is the same. Add a strict=false in
case people need it for validation, better yet, add a validation helper
function, but always return the proper form.
2. A host address is an IP address with no network info. No mask
What about Broadcast / Network IDs?
The "Network-ID or Network Number" and "Broadcast" are meaningless without
1. A network number by itself it's just another address. Its use depends on
context. When routing, it needs a mask.
> route 10.0.0.0 255.0.0.0 192.168.1.1
When writing firewall ACLs, it is a host.
> access-list aclname permit ip any 192.168.1.2 255.255.255.254
Since both are valid, preference shouldn't be given. Instead add a helper
2. Same story with broadcast. Use depends on context. Add the lastip helper.
What does iterating over a network mean?
Iterating over the set of addresses in a network must return host addresses.
If it returns a network, then the address should be ANDed, but that would
return the same number for every iteration. Only returning hosts makes
We need to set a solid line between IP String manipulation and IP
If you want an IP with a mask that isn't a network, then you're not doing IP
address manipulation, you're doing string manipulation. There are many use
cases for it, but it's a separate consideration to pure IP manipulation.
If string manipulation is desirable, then add another standard library
called ipstring (or a separate class if you want it all jumbled in the same
import). This way real network computing can be done without weird quirks
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev