code: def parcompute_example():
      dc = PMPExample()
      dc2 = PMPExample()
      dc3 = PMPExample()
      dc4 = PMPExample()
  
      n_datapoints = 100
      inp_data = range(n_datapoints)
      r1 = dc.threadcompute(inp_data)
      assert len(dc.cache) == n_datapoints
  
      r2 = dc2.processcompute(inp_data)
      assert len(dc2.cache) == 0
      assert r1 == r2
  
      r3 = ProcessPool(4).map(dc3.compute, inp_data)
      r4 = ThreadPool(4).map(dc4.compute, inp_data)
      ProcessPool.__state__.clear()
      ThreadPool.__state__.clear()
      assert r4 == r3 == r2
      assert len(dc3.cache) == 0
      assert len(dc4.cache) == n_datapoints
  
      log.info(
          "Size of threadpooled class caches: {0}, {1}".format(
              len(dc.cache), len(dc4.cache)
          )
      )
      log.info(
          "Size of processpooled class caches: {0}, {1}".format(
              len(dc2.cache), len(dc3.cache)
          )
      )
  
file_path: pathos/examples/mp_class_example.py
imports: from pathos.pools import ProcessPool, ThreadPool
  import logging
label_desc: Use image node_id 1 for calling a global function with example usage: parcompute_example() without return types