Message233083
| Author |
eric.snow |
| Recipients |
eric.snow, josh.r, lemburg, ncoghlan, pmoody, r.david.murray, rhettinger, sbromberger, serhiy.storchaka |
| Date |
2014年12月24日.17:22:27 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1419441748.1.0.0798850527575.issue23103@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
@sbromberger, there's no need for your own package. Just use something like this:
_addr_cache = {}
def ipaddr(addr):
try:
return _addr_cache[addr]
except KeyError:
_addr_cache[addr] = ipaddress.ipaddress(addr)
return _addr_cache[addr]
You could even throw weakrefs in there if your use case demanded it. |
|