New submission from Jeff Reback:
xref to https://github.com/pandas-dev/pandas/issues/14679.
pandas has had a cython extension class to datetime.datetime for quite some
time. A simple __reduce__ is defined.
def __reduce__(self):
object_state = self.value, self.freq, self.tzinfo
print(object_state)
return (Timestamp, object_state)
In 3.5.2:
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:52:12)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> import pickle
>>> pickle.dumps(pd.Timestamp('20130101'))
(13569984000, None, None)
b'\x80\x03cpandas.tslib\nTimestamp\nq\x00\x8a\x08\x00\x00\xc6\xe8\xda\x06\xd5\x12NN\x87q\x01Rq\x02.'
But in 3.6.03b
Python 3.6.0b3 | packaged by conda-forge | (default, Nov 2 2016, 03:28:12)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> import pickle
>>> pickle.dumps(pd.Timestamp('20130101'))
b'\x80\x03cpandas.tslib\nTimestamp\nq\x00C\n\x07\xdd\x01\x01\x00\x00\x00\x00\x00\x00q\x01\x85q\x02Rq\x03.'
So it appears __reduce__ is no longer called at all (I tried defining
__getstate__, __getnewargs__ as well, but to no avail). Instead it looks like
datetime.datetime.__reduce__ (well a c function is actually called).
Link to the codebase.
https://github.com/pandas-dev/pandas/blob/master/pandas/tslib.pyx#L490
--
components: IO
messages: 281070
nosy: Jeff Reback
priority: normal
severity: normal
status: open
title: __reduce__ not being called in dervied extension class from
datetime.datetime
type: behavior
versions: Python 3.6
___
Python tracker
<http://bugs.python.org/issue28730>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com