Skip to content
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

WIP, ENH: Buffer Support for DateTime Array #15309

Closed
wants to merge 2 commits into from

Conversation

WillAyd
Copy link
Contributor

@WillAyd WillAyd commented Jan 10, 2020

closes #4983

I don't believe this is mergeable in current state but hoping that this is moving in the right direction.

Currently this allows writing of datetime arrays as their integer values but round-tripping is not really possible. I think what we might want to do instead is add a format for a struct that contains the value and information around the precision, so something like i:val:2c:unit (untested)

@eric-wieser
Copy link
Member

I think what we might want to do instead is add a format for a struct that contains the value and information around the precision

Added a comment with an idea about that at #4983 (comment)

@seberg
Copy link
Member

seberg commented Jan 10, 2020

I have to confess that I will need a lot of convincing to put this in. This is because it loses information so we should not be doing it silently in my opinion. If someone has a C-function which makes sense for int64, there is no guarantee that it will do something sensible for datetimes, but this way any such (e.g. cython) function will just accept it happily.

Erics suggestion may be an option (although quite frankly, it is may be too much complexity for my liking; Maybe we should rather think about growing the buffer protocol). But: at least such a hack gives you a strange datatype that the consumer will not accidentally interpret as an int64 even though it is not really one.
OTOH, the suggestion at least somewhat encompasses possible future use cases where you could have say quaternion as a named, specialized, structured (like) dtype...

@WillAyd
Copy link
Contributor Author

WillAyd commented Jan 10, 2020

Thanks for the feedback! @seberg what do you mean by "growing the buffer protocol"? I'm not as super well versed in this as you both, but IIUC what @eric-wieser is saying we could in theory leverage the existing format specifiers to disambiguate this from integer values (?)

@seberg
Copy link
Member

seberg commented Jan 10, 2020

What I mean is ammend/createa Python Enhancement Proposal with the idea to somehow encompass more specialized types. Although I have no idea how that could look like...

@charris charris changed the title Buffer Support for DateTime Array WIP, ENH: Buffer Support for DateTime Array Jan 15, 2020
@WillAyd
Copy link
Contributor Author

WillAyd commented Jan 16, 2020

closing for now but thanks for the insights. Will think through and re-open if something better comes to mind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

datetime64 arrays don't support buffer protocol
4 participants