[ZODB-Dev] Storing persistent and non-persistent data together
Tim Peters
tim at zope.com
Mon Dec 6 11:24:32 EST 2004
[Eric Mangold]
> I'm thinking about using my own _p_ attributes for non-persistent data.
> Then, I can re-set those _p_ attributes inside __setstate__. My testing
> indicates that this will work.
>
> Does anyone see any problems with creating custom _p_ attributes?
Yes: attribute names starting with "_p_" are reserved for the
implementation. Nothing is defined about what happens if you try to invent
your own, and they're special-cased all over the place in undocumented,
unadvertised, and unsupported ways (and since they're internal
implementation details, that's appropriate). So, if you invent one, you're
entirely on your own.
I don't know what your testing consisted of, but I suspect it would have
worked just as well if you had used _v_ attributes instead. While there's
no guarantee that _v_ attributes persist, there's no guarantee that made-up
_p_ attributes will either. What do you think using _p_ buys you that _v_
would not?
More information about the ZODB-Dev
mailing list