Faster copying of composite new-class objects

A

Alex

Hi,

My program requires copying thousands of composite new-class objects. I
found that the following: objCopy=cPickle.loads(cPickle.dumps(obj,
protocol=2)) works about 4 times faster than
copyObj=copy.deepcopy(obj). Is there any way to do it even faster?

All objects have slots, __getstate__ and __setstate__.

TIA,

Alex
 
J

John J. Lee

Alex said:
My program requires copying thousands of composite new-class objects. I
found that the following: objCopy=cPickle.loads(cPickle.dumps(obj,
protocol=2)) works about 4 times faster than
copyObj=copy.deepcopy(obj). Is there any way to do it even faster?

All objects have slots, __getstate__ and __setstate__.

At a wild guess: writing custom serialisation functions using module
marshal?


John
 

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

Forum statistics

Threads
474,274
Messages
2,571,368
Members
48,060
Latest member
JerrodSimc

Latest Threads

Top