1

I have problem with the netaddr package - version 0.7.5. This code works as expected and prints out the list of ip addresses in the range:

from netaddr import IPNetwork
ipnetwork = '192.168.0.0/24'
print list(IPNetwork(ipnetwork).iter_hosts())

However, if I change the network to, say, '192.168.0.0/8' my script just hangs:

from netaddr import IPNetwork
ipnetwork = '192.168.0.0/8'
print list(IPNetwork(ipnetwork).iter_hosts())

Am I missing something or is this a bug?

EDIT

Looks like I was missing something by not realising how big that range is!

asked Jan 16, 2011 at 15:21

1 Answer 1

2

Are you sure that it's not just taking a lot of time? You are making a list out of the iterator. When I run that on my machine, I get 100% CPU usage and memory usage increase. I can also print out the entire range if I use the iterator directly.

answered Jan 16, 2011 at 15:27
Sign up to request clarification or add additional context in comments.

2 Comments

Whoops, sorry I've just done that. I didn't realise the range was so big.
@normski Yup, 2**24 elements, totally nothing special =)

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.