[lxml-dev] pickling ElementStringResult
Martijn Faassen
faassen at startifact.com
Fri Jun 27 11:03:15 CEST 2008
Hi there,
On Fri, Jun 27, 2008 at 7:50 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
[snip]
> Wouldn't it be enough to pickle the string subclass as a plain (unicode)
> string? You would obviously loose information that way, but pickling the
> string result together with the entire tree would be much more surprising IMHO.
Sorry for being unclear, I'm not suggesting that the entire tree
should be pickled.
The ZODB has a cache, which is simply some of the "recently touched"
Python objects in memory. I have no idea how long the object in
question will remain in the ZODB cache (i.e. just a normal Python
object in memory). It could be there for hours, days, depending on
activity and cache size, etc. The smart string keeps the document it
was in awake, possibly way past the expected time, and the document
will only be collected if the object is removed from the ZODB cache,
which I can't predict very well. Only when the smart string is pickled
would the reference with the document be broken. At least, I *think*
this is how it works. So, while pickling happens immediately, the
object doesn't disappear right away after pickling, keeping this
reference alive.
In think in general smart strings behave somewhat unexpectedly in the
face of potentially long-running processes. One is inclined to treat
them as strings, but their memory behavior is quite different.
Regards,
Martijn
More information about the lxml-dev
mailing list