title: python3 memoryerror when producing a large list
body: <p>I'm a beginner. I recently see the <a href="https://en.wikipedia.org/wiki/Mandelbrot_set" rel="nofollow">Mandelbrot</a> set which is fantastic, so I decide to draw this set with python.
  But there is a problem,I got 'memoryerror' when I run this code.</p>
  
  <p>This statement <code>num_set = gen_num_set(10000)</code> will produce a large list, about 20000*20000*4 = 1600000000. When I use '1000' instead of '10000', I can run code successfully.</p>
  
  <p>My computer's memory is 4GB and the operating system is window7 32bit. I want to know if this problem is limit of my computer or there is some way to optimize my code.</p>
  
  <p>Thanks. </p>
  
  <pre><code>#!/usr/bin/env python3.4
  
  import matplotlib.pyplot as plt
  import numpy as np
  import random,time
  from multiprocessing import *
  
  def first_quadrant(n):
      start_point = 1 / n
      n = 2*n
      return gen_complex_num(start_point,n,1)        
  
  def second_quadrant(n):
      start_point = 1 / n
      n = 2*n
      return gen_complex_num(start_point,n,2)
  
  def third_quadrant(n):
      start_point = 1 / n
      n = 2*n
      return gen_complex_num(start_point,n,3)
  
  def four_quadrant(n):
      start_point = 1 / n
      n = 2*n
      return gen_complex_num(start_point,n,4)
  
  def gen_complex_num(start_point,n,quadrant):
      complex_num = []
      if quadrant == 1:        
          for i in range(n):
              real = i*start_point
              for j in range(n):
                  imag = j*start_point
                  complex_num.append(complex(real,imag))
          return complex_num
      elif quadrant == 2:
          for i in range(n):
              real = i*start_point*(-1)
              for j in range(n):
                  imag = j*start_point
                  complex_num.append(complex(real,imag))
          return complex_num
      elif quadrant == 3:
          for i in range(n):
              real = i*start_point*(-1)
              for j in range(n):
                  imag = j*start_point*(-1)
                  complex_num.append(complex(real,imag))
          return complex_num
      elif quadrant == 4:
          for i in range(n):
              real = i*start_point
              for j in range(n):
                  imag = j*start_point*(-1)
                  complex_num.append(complex(real,imag))
          return complex_num            
  
  def gen_num_set(n):
      return [first_quadrant(n), second_quadrant(n), third_quadrant(n), four_quadrant(n)]
  
  def if_man_set(num_set):
      iteration_n = 10000
      man_set = []
      z = complex(0,0)
      for c in num_set:
          if_man = 1
          for i in range(iteration_n):
              if abs(z) &gt; 2:
                  if_man = 0
                  z = complex(0,0)
                  break
              z = z*z + c
          if if_man:          
              man_set.append(c)        
      return man_set
  
  
  def plot_scatter(x,y):
      #plt.plot(x,y)
  
      color = ran_color()
      plt.scatter(x,y,c=color)
      plt.show()
  
  def ran_num():
      return random.random()
  
  def ran_color():
      return [ran_num() for i in range(3)]
  
  def plot_man_set(man_set):
      z_real = []
      z_imag = []
      for z in man_set:
          z_real.append(z.real)
          z_imag.append(z.imag)
      plot_scatter(z_real,z_imag)
  
  
  if __name__ == "__main__":
      start_time = time.time()
      num_set = gen_num_set(10000)    
      with Pool(processes=4) as pool:
          #use multiprocess
          set_part = pool.map(if_man_set, num_set)
      man_set = []
      for i in set_part:
          man_set += i
      plot_man_set(man_set)
      end_time = time.time()
      use_time = end_time - start_time
      print(use_time)
  </code></pre>