#11461: make @parallel work with class/instance methods
---------------------------+------------------------------------------------
   Reporter:  niles        |          Owner:  tbd               
       Type:  defect       |         Status:  new               
   Priority:  major        |      Milestone:  sage-4.7.1        
  Component:  performance  |       Keywords:  parallel decorator
Work_issues:               |       Upstream:  N/A               
   Reviewer:               |         Author:                    
     Merged:               |   Dependencies:                    
---------------------------+------------------------------------------------

Comment(by niles):

 I wish I could tell buildbot not to apply [attachment:parallel.patch] -- I
 put it here only to share what I've learned about how `@parallel` works:
 The object that gets passed to `Parallel` is no longer a method, but only
 a plain function.  Here's how I'm testing this:

 First, the following goes in a separate file

 {{{
 @parallel
 def func(n):
     sleep(.2)
     return prime_pi(n)

 class PTest(SageObject):
     attr = 'red'
     def meth0(self,n):
         return n
     @parallel
     def meth1(self,n):
         "long and complicated class method"
         sleep(.5)
         return [prime_pi(n),self.attr]

 N = PTest()
 M = [1000,2000,3000,4000,5000]
 L = [(N,x) for x in [1000,2000,3000,4000,5000]]
 }}}

 Then I apply the patch and do this:
 {{{
 sage: N.meth1(100)
 args: (<class '__main__.PTest'>, 100)
 branch 2.5.1
 ...
 NotImplementedError: this branch not finished

 sage: func(100)
 args: (100,)
 branch 2.5.1
 ...
 NotImplementedError: this branch not finished
 }}}

 So the function and method are being treated the same by `Parallel`.  None
 of the ideas for detecting the difference: `.__self__`, `ismethod`, or
 `isfunction` seem to work.  So I guess this means something earlier in the
 application of `@parallel` needs to be fixed.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11461#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to