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
After fixing the first issue by replacing self.__dict__ with self.__slots__, one passes a datatype into copy.deepcopy (or specifically for my case, as a field on a dataclass, which gets passed into dataclasses.asdict) will quickly find that the function relies on the data structure having the __dict__ attribute and as a result throws: https://github.com/python/cpython/blob/6359141867595f84f9e803e1053ae51db3203c49/Lib/copy.py#L268
Indeed the __reduce__ method is no longer correct.
However, if I simply remove that method, deepcopy seems to work just fine. Could you elaborate on your point 2? I cannot reproduce your example if __reduce__ is deleted.
Checks
Issue description
The issue is twofold:
__slots__
to most Polars classes #13236 added the__slots__
attributes to all the datatypes, which forced the removal of__dict__
. However, on https://github.com/Object905/polars/blob/815732bc0f5bc06e07f3a995c164fa87e3c53ce8/py-polars/polars/datatypes/classes.py#L94__dict__
is still being accessedself.__dict__
withself.__slots__
, one passes a datatype intocopy.deepcopy
(or specifically for my case, as a field on a dataclass, which gets passed intodataclasses.asdict
) will quickly find that the function relies on the data structure having the__dict__
attribute and as a result throws: https://github.com/python/cpython/blob/6359141867595f84f9e803e1053ae51db3203c49/Lib/copy.py#L268Reproducible example
self.__dict__
withself.__slots__
)Expected behavior
polars datatypes can be safely passed into
copy.deepcopy
Installed versions
The text was updated successfully, but these errors were encountered: