title: How to overcome joblib's "TypeError: can't pickle instancemethod objects" on class method?
body: <p>Given a class and 2 methods in it A, B.</p>
  
  <p>I am getting a "TypeError: can't pickle instancemethod objects" when trying to execute the following command while in A:</p>
  
  <pre><code>joblib.Parallel(n_jobs=-1)(joblib.delayed(self.B)(arg1, arg2, arg3) for arg1 in arg1_values_list)
  </code></pre>
  
  <p>I found several threads on Stackoverflow regarding instancemethod and part of them are even related to joblib, but I still didn't manage to overcome this error.</p>
  
  <blockquote>
    <p>EDIT:</p>
  </blockquote>
  
  <p>The following code:</p>
  
  <pre><code>from sklearn.externals.joblib import Parallel, delayed
  def a(self, x):
      print x
      return x*10
  
  class c(object):
      def b(self):
          Parallel(n_jobs=-1)(
              delayed(a)(self, i) 
              for i in range(10))
  
  test_c = c()
  
  test_c.b()
  </code></pre>
  
  <p>runs ok when normally ran.</p>
  
  <p>but fails when trying to profile using "python -m cProfile"</p>