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
Identical timezones don't compare equal, since equality is currently implemented via instance comparison.
In [28]: frompendulum.tz.timezoneimportTimezoneIn [29]: t1=Timezone("UTC")
In [30]: t2=Timezone("UTC")
In [31]: t1==t2Out[31]: False
This is most likely to come up when pickling pendulum instances - when unpickled the timezone instances will no longer match:
In [44]: importpendulumIn [45]: importpickleIn [46]: t=pendulum.now()
In [47]: t2=pickle.loads(pickle.dumps(t))
In [48]: t.tzinfoOut[48]: Timezone('America/Chicago')
In [49]: t2.tzinfoOut[49]: Timezone('America/Chicago')
In [50]: t.tzinfo==t2.tzinfo. # I'd expect this to be trueOut[50]: False
This came up when using pendulum objects with pandas and dask. Some pandas methods validate the datetime objects input by checking that all provided timezones are identical. After deserializing the pendulum objects, the timezones no longer compared identical, even though they were equivalent.
It looks like there was an intent to cache instances with the same name here:
Since the unpickling code doesn't go through this path, the cache isn't used on load. Either the caching should be moved into the classes themselves, or __eq__ should be implemented so multiple equivalent instances still compare equal.
The text was updated successfully, but these errors were encountered:
Identical timezones don't compare equal, since equality is currently implemented via instance comparison.
This is most likely to come up when pickling
pendulum
instances - when unpickled the timezone instances will no longer match:This came up when using pendulum objects with
pandas
anddask
. Some pandas methods validate the datetime objects input by checking that all provided timezones are identical. After deserializing the pendulum objects, the timezones no longer compared identical, even though they were equivalent.It looks like there was an intent to cache instances with the same name here:
https://github.com/sdispater/pendulum/blob/daa4b936daf3f4dfa7d211aa0ac1e9d82d5401d4/pendulum/tz/__init__.py#L34-L35
Since the unpickling code doesn't go through this path, the cache isn't used on load. Either the caching should be moved into the classes themselves, or
__eq__
should be implemented so multiple equivalent instances still compare equal.The text was updated successfully, but these errors were encountered: