[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

psyco class question

Magdoll

3/17/2008 2:30:00 AM

I can't find a psyco mailing list that I can directly ask to (so point
me to it if there is one), so I'm posting it here. I know very little
about how types and classes work in python and this is probably why
I'm having trouble.

I wrote a class inheriting pysco.classes, and the class structure is
like this:

class Node(psyco.classes.psyobj):
def __init__(self,a,b,c...):
self.a = a
self.b = b
etc....

this all works very well and speeds up the code tremendously. But when
I try to pickle it:

from cPickle import *
s = Node(<some parameters here>)
f = open('test.pickle','w')
dump(s,f)
f.close()

It gives me errors like:

Traceback (most recent call last):
File "y.py", line 13, in <module>
dump(a,f)
File "/usr/lib/python2.5/pickle.py", line 1362, in dump
Pickler(file, protocol).dump(obj)
File "/usr/lib/python2.5/pickle.py", line 224, in dump
self.save(obj)
File "/usr/lib/python2.5/pickle.py", line 306, in save
rv = reduce(self.proto)
File "/usr/lib/python2.5/copy_reg.py", line 70, in _reduce_ex
state = base(self)
TypeError: default __new__ takes no parameters


If I embed Node in some other structures (I actually used it as nodes
in a networkx.XGraph()), the dumping doesn't give me errors but when I
load the pickle I get errors saying that the state is not a
dictionary.

What is the cause of the error? Is it because psyco classes uses its
own class types that can't be pickled or do I need to override
something?

Thanks in advance.
Magdoll