fast deep-copying of instances
Michal Vitecek
fuf at mageo.cz
Wed Jan 28 10:48:00 EST 2004
Robert Brewer wrote:
>Michal Vitecek wrote:
>> hello,
>>
>> i have a data cache which sits between a slow database and
>> my server and
>> it's used to cache data retrieved from the database. in
>> order for it to
>> work correctly (race-conditions) i need a fast deep-copying of
>> instances (the cache is used heavily).
>>
>> i tried to use copy module but it's *very* slow, then i tried cPickle
>> to pickle and depickle instances which was faster, but still slow.
>>
>> then i've come across cCopy which is 8x faster than copy, but
>> unfortunately it doesn't work with new style classes because type()'s
>> return is crappy for them. so the question is: does there
>> exist a fast
>> copy module which works with new style classes?
>
>If you don't find something pre-built, you can always build it yourself
>into the classes which you are caching, via __copy__ and __deepcopy__
>methods.:
i know of this mechanism but
a) i fear it would be still slower than cPickle and be quite time
consuming to implement (lots of classes)
b) cCopy is the C implementation of the copy module so it's
"lightning" fast
the current cCopy is at http://www.jessikat.fsnet.co.uk/cCopy.html . if
someone would be so kind to add support for new style classes to it (or
tell me how to do it), i'd be very very grateful.
thank you,
--
fuf (fuf at mageo.cz)
More information about the Python-list
mailing list