[Python-Dev] PEP 3144: IP Address Manipulation Library for the Python Standard Library
tino at wildenhain.de
Wed Aug 19 15:47:19 CEST 2009
Antoine Pitrou wrote:
> Le Tue, 18 Aug 2009 13:00:06 -0700, Peter Moody a écrit :
>> Howdy folks,
>> I have a first draft of a PEP for including an IP address manipulation
>> library in the python stdlib. It seems like there are a lot of really
>> smart folks with some, ahem, strong ideas about what an IP address
>> module should and shouldn't be so I wanted to solicit your input on this
> When you say :
> « the results of the first computation should be cached and only
> re-generated should the object properties change »
> does it mean that the objects are mutable? Would it make sense to make
> them immutable and therefore hashable (such as, e.g., datetime objects)?
They could impelement __hash__ to behave correctly in this case.
In the examples however I see:
this is often used but not the only valid broadcast address,
in fact, any address between network address and max(address with given
netmask) can be defined as broadcast. Maybe biggest or greatest
would be better name for the attribute. User is then free to interpret
it as broadcast if desired.
The attribute network returned as address object also does not seem
The performance hit you mention by translating the object upfront
is neglegtible I'd say - for any sensible use of the object you'd
need the binary form anyway. You can even use system (e.g. socket)
funtions to make the translation very fast. This also safes space
and allow vor verification of the input.
(e.g. '255.255.255.255/32' is 18 bytes where it could
be stored as 8 bytes instead (or even 5 if you use
I have a very very old implementation which even did the
translation from cidr format to integer in python code
(I don't say plain ;) but maybe worth a look:
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3241 bytes
Desc: S/MIME Cryptographic Signature
More information about the Python-Dev