-
Notifications
You must be signed in to change notification settings - Fork 267
Proposed API change: netcdftime.datetime should be immutable #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Sounds reasonable to me. |
Is a pull request coming? |
Yes, when I have the time to get it together :). On Wed, May 14, 2014 at 12:48 PM, Jeff Whitaker [email protected]
|
No problem, just checking.. |
ddasilva
pushed a commit
to ddasilva/netcdf4-python
that referenced
this issue
Jul 4, 2014
ddasilva
pushed a commit
to ddasilva/netcdf4-python
that referenced
this issue
Jul 4, 2014
ddasilva
pushed a commit
to ddasilva/netcdf4-python
that referenced
this issue
Jul 4, 2014
ddasilva
pushed a commit
to ddasilva/netcdf4-python
that referenced
this issue
Jul 4, 2014
jswhit
added a commit
that referenced
this issue
Jul 8, 2014
Make netcdftime.datetime immutable and hashable. Fixes #255.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If we make
netcdftime.datetime
immutable, we can define a__hash__
method and thus use these objects as a dictionary keys. Note that python's standard library datetime.datetime object is immutable for precisely this reason.Why is this useful? In xray, we use netCDF4 to decode dates with non-standard calendars, and (currently) store the results as an array of
netcdftime.datetime
objects. If these objects were hashable, it would be possible to use datetime objects to perform fast location based lookups (using a hash table) along a time dimension labeled by these phony datetime objects.I doubt that this will break anyone's code, since it would be weird to mutate a datetime object in-place, but since this would change the existing API I thought it would be worth discussing before filing a pull request. At the very least, I think mutating a datetime object should be deprecated, so that it is possible change this behavior in a future release.
The text was updated successfully, but these errors were encountered: