Message233052
| Author |
sbromberger |
| Recipients |
josh.r, ncoghlan, pmoody, r.david.murray, sbromberger, serhiy.storchaka |
| Date |
2014年12月23日.16:29:57 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1419352197.47.0.223627339081.issue23103@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
1) However:
>>> b = ipaddress.IPv4Address('1.2.3.4')
>>> a = ipaddress.IPv4Address('1.2.3.4')
>>> id(a)
4428380928
>>> id(b)
4428381768
>>> a == b
True
>>> b._ip += 6
>>> id(b)
4428381768
>>> b
IPv4Address('1.2.3.10')
2) Isn’t _version already a class attribute? It’s set in _Basev4/Basev6.
3) Memory consumption seems particularly wasteful in the current implementation: it takes 56 bytes (via sys.getsizeof) to store what amounts to 4 bytes of data.
I thought about subclassing Int as well, and I agree it’s the wrong approach. There are too many int methods that don’t make sense in the context of IP addresses. |
|