You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In []: attrs.__version__
Out[]: '25.3.0'
In []: a = A()
In []: a.x
caching
Out[]: [0, 1, 2, 3, 4]
In []: a.x
Out[]: [0, 1, 2, 3, 4]
a.x is cached. However, if I round trip through pickle:
In []: pickle.loads(pickle.dumps(a)).x
caching
Out[]: [0, 1, 2, 3, 4]
the cached property is rebuilt. Usually when I used cached properties, it's to hold expensive data, and it would be nice to capture this in a pickle. Can this be supported?
The text was updated successfully, but these errors were encountered:
This seems dangerous and would have to be pre-property opt-in and I’m not sure how to do that. Just imagine the cached property determines something that is specific to the current process or machine.
If you want pickled expensive fields, I would recommend a classmethod constructor.
Consider the following
The following behavior is expected:
a.x is cached. However, if I round trip through pickle:
the cached property is rebuilt. Usually when I used cached properties, it's to hold expensive data, and it would be nice to capture this in a pickle. Can this be supported?
The text was updated successfully, but these errors were encountered: