SystemError: error return without exception set

2010-02-26 Thread Shailendra
Hi All,
I am getting error in "SystemError: error return without exception
set" which i am not able debug. I made following test program which
gives same error.

=test.py==

import numpy

class testClass:
def __init__(self,param1=1,param2=2):
self.param1,self.param2=param1,param2

def __str__(self):
return 'param1=%d param2=%d'%(self.param1,self.param2)


class makeLotOftestClass:
def __init__(self,paramlist1=None,paramlist2=None):
self.holder= numpy.empty((len(paramlist1),len(paramlist2)))
for i in range(len(paramlist1)):
for j in range(len(paramlist2)):

self.holder[i,j]=testClass(param1=paramlist1[i],param2=paramlist2[j])

def __str__():
str=''
for testclass in numpy.raven(self.holder):
str=str+testclass.__str__()
return str

if __name__=='__main__':

lotofclass=makeLotOftestClass(paramlist1=[10,20,30,40],paramlist2=[110,120,130,140])
print lotofclass

==

$ python test.py
Traceback (most recent call last):
  File "test.py", line 25, in 

lotofclass=makeLotOftestClass(paramlist1=[10,20,30,40],paramlist2=[110,120,130,140])
  File "test.py", line 16, in __init__
self.holder[i,j]=testClass(param1=paramlist1[i],param2=paramlist2[j])
SystemError: error return without exception set

Can someone point out why is this exception. It seems to be a simple
code. Google search for the error message did not help much.

Thanks,
Shailendra
-- 
http://mail.python.org/mailman/listinfo/python-list


Multiprocessing taking too much time

2010-07-29 Thread Shailendra
Hi All,
I have a following situation.
==PSUDO CODE START==
class holds_big_array:
    big_array  #has a big array

    def get_some_element(self, cond) # return some data from the array
from the big array
==PSUDO CODE END
I wanted to use multiprocessing module to parallelise calling
"get_some_element". I used following kind of code

==PSUDO CODE START==
pool = Pool(processes=2)
holder =holds_big_array() #class instantiation
def callback_f(result):
         do something with result
loop many times
   pool.apply_async(holder.get_some_element,args,callback=callback_f)
pool.close()
pool.join()
==PSUDO CODE END
Note: Had to do something to enable instance method being pickled...

I tested this with less than realistic size of big_array . My parallel
version works much slower than than the normal serial version (10-20
sec vs 7-8 min). I was wonder what could be the possible reason. Is it
something to do that it is a instance method and some locking will
make other process wait for the locks. Any idea how to trace where the
program is spending time?

Let me know if the information give is inadequate.

Thanks in advance.
Shailendra Vikas
-- 
http://mail.python.org/mailman/listinfo/python-list