title: Ping sweep fast in python
body: <p>I have two ways to ping a network (using the python nettaddr library).</p>
  <p>Option 1</p>
  <pre><code>from netaddr import *
  from ping3 import ping
  import subprocess
  
  
  ip = IPNetwork('192.168.1.0/24')
  print (list(ip))
  
  for ip in IPNetwork('192.168.1.0/24'):
  
      response = os.system(&quot;ping -c 1 &quot; + str(ip))
  
      #and then check the response...
      if response == 0:
          print (ip, 'is up!')
      else:
          print (ip, 'is down!')
  </code></pre>
  <p>Option 2</p>
  <pre><code>for ip in IPNetwork('192.168.1.0/24'):
  
      response = subprocess.Popen(&quot;ping -c 1 &quot; + str(ip),stdout=subprocess.PIPE, shell=True)
  
      response.wait()
  
      if response.poll()==0:
  
          print (ip)
  </code></pre>
  <p>The problem is that I find both of them very slow, for a /24 network they take about several minutes, and I would need it to be much faster.</p>
  <p>Any simple and efficient way in python to do this?</p>