What's the closest implementation of scala's '@transient lazy val' in Python?
<p>According to this post:</p>

<p><a href="http://stackoverflow.com/questions/3012421/python-memoising-deferred-lookup-property-decorator">Python memoising/deferred lookup property decorator</a></p>

<p>A mnemonic decorator can be used to declare a lazy property in a class. There is even an 'official' package that can be used out of the box:</p>

<p><a href="https://pypi.python.org/pypi/lazy" rel="nofollow">https://pypi.python.org/pypi/lazy</a></p>

<p>however, both of these implementation has a severe problem: any memorized values will be attempted to be pickled by python. If these values are unpicklable it will cause the program to break down.</p>

<p>My question is: is there an easy way to implement scala's "@transient lazy val" declaration without too much tinkering? This declaration should remember the property in case of multiple invocation, and drop it once the class/object is serialized.</p>

<p>Unaware of scala implementation details, but the easiest solution comes to my mind, if you're satisfied with other aspects of the 'lazy property' library you've found, would be implementing <code>__getstate__</code> and <code>__setstate__</code> object methods, as described in <a href="https://docs.python.org/2/library/pickle.html#pickling-and-unpickling-normal-class-instances" rel="nofollow">Pickling and unpickling normal class instances</a></p>

<p>These methods are called by pickle/unpickle handler during object instance (de)serialization.</p>

<p>This way you can have fine-grained control of how/which attributes of your object serialized. 
You should read corresponding documentation on another two pickle-related methods as well (take care of <code>__getinitargs__</code> specifically).
Python deserialized objects initialization differes from common <code>__new__</code> &amp; <code>__init__</code> sequence</p>

python serialization pickle lazy-evaluation