-
Notifications
You must be signed in to change notification settings - Fork 291
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
Add IBufferProtocol to mmap #1866
base: main
Are you sure you want to change the base?
Conversation
Yes, I have been thinking about the buffer protocol for large blobs, though not in the context of I was thinking of supporting Numpy's ND arrays, which can be really big too. Also on some .NET versions, CLI arrays can be up to 4GB. The latter is exotic and the former still a little bit away, but The idea is to make it still easy to support by various types that implement the buffer protocol, and relatively easy to use by consumers. I am wary of using too much of I see the following three major consuming patterns that should be easy for consumers to implement:
I was thinking along these lines:
The file descriptor work seems to be finally coming to an end, so once you merge this PR I could play with these ideas in code to get some better insights. |
Add
IBufferProtocol
tommap
. Throws aNotImplementedException
if the length does not fit in aint
.For the case of bigger files I think we'll have to rework
IPythonBuffer
. My initial thoughts on changes would be:nint
in place ofint
where applicable (probably where CPython usesPy_ssize_t
).AsSpan
/AsReadOnlySpan
methods to have annint start
argument.nint
arithmetic instead ofint
.Marking as draft since I need to do more testing (and maybe write some tests). @BCSharp I'm not sure if you looked at/thought about this before so if you have any feedback would appreciate it.
Related to #1408