Controlling copying and pickling of objects written in C

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sun Apr 13 15:49:51 EDT 2008


En Sun, 13 Apr 2008 01:57:42 -0300, Adam Bregenzer  
<adam_no_spam at no_s.p.a.m.bregenzer.net> escribió:

> I am writing an extension and have "hidden" data included in the object's
> C structure that is not visible to python.  I am unsure what would happen
> to that data if the python object were copied or pickled and would prefer
> to raise an exception whenever code tries to copy/deep copy/pickle or
> marshal the object since it would not make sense.  Where would I look to
> control that?

You could raise an exception in __getstate__ - that would make pickle  
fail, and probably copy too but I'm not sure of that.

-- 
Gabriel Genellina




More information about the Python-list mailing list