[issue20860] ipaddress network subnets() method should return object with __getitem__
Warren Turkal
report at bugs.python.org
Thu Mar 6 22:53:31 CET 2014
Warren Turkal added the comment:
Won't that instantiate an object for each item in the list though? For example:
>>> list(net.subnets(prefixlen_diff=16))[499]
This take a long time. I was trying to think of a way to lazily instantiate.
For example, I don't want to create 65536 network objects (like above) if I am looking for the 500th /24 subnet of 10.0.0.0/8. The following executes much more quickly:
>>> ipa.ip_network((10 << 24) + (499 << 8))
That essentially what the __getattr__ method should do. Of course, it might also be nice to have a __len__ on that object.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20860>
_______________________________________
More information about the Python-bugs-list
mailing list