is copy_reg still 'proper' ?

Pete Shinners pete at
Fri Oct 26 00:01:00 CEST 2001

i've got some extention type objects that i'd like to be pickleable. 
from what i can see in the docs, i should be using the "copy_reg" 
module? it doesn't seem like it will be hard to do, but i've got a 
couple questions.

is "copy_reg" still the recommended way of doing this? i wasn't sure if 
i should instead do something with __setstate__ and __getstate__.

i also wonder when is the 'best' time to install my stuff into copy_reg. 
should i do it when my module is imported? maybe when that type of 
object is first instantiated?

is this being changed at all in python 2.2?

last question is the use of the constructor() function in copy_reg. i 
see that making extension types callable makes them convenient 
constructor functions, but what benefit would there be to keeping a 
separate list of these in the copy_reg module? i couldn't think of any 
meaningful use for this, and i'm curious? which modules use this? also, 
what type of arguments get passed to the constructor when this is used?

thanks all, i'm mainly just wondering if registering with copy_reg is 
the best way to do this sort of thing?

More information about the Python-list mailing list