psyco class question

M

Magdoll

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,078
Latest member
MakersCBDBlood

Latest Threads

Top