-
Notifications
You must be signed in to change notification settings - Fork 258
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
MRG: expanding, rethinking mmap'ing #267
Conversation
Check that BytesIO raises UnsupportedOperation, and other types have non-zero fileno.
Test that ``array_from_file`` works correctly with ``Opener`` instances.
bz2 file does not have fileno in Python 3.2 and 2.7 on travis at least.
Test for gzip / bz2 file object, so we can in due course avoid memory-mapping these guys in ``array_from_file``.
If we can change strings loaded from files without messing up the result of a subsequent load, then we can use the string memory as modifiable memory backing the array returned from `array_from_file`.
Check that reading an array, modifying the array, then rereading the array, returns the same result for both reads.
Use test for compressed files so we don't mmap them. Numpy was trying to mmap bz2 files. Following suggestion from Nathaniel, use `readinto` method of most file-like objects to read data into given memory location, so we can be sure that memory location is not used by some other object. If we can't use `readinto`, use heuristic to guess whether we can re-use memory from file bytes read for array memory store. Use bytearray to read data into, to avoid complications with numpy array.data buffers and Python 3 / "non-native" datatypes.
Benchmarks ( This is the second to last PR before the release - we are in the home stretch - any takers? |
Add tests that unscaled image returns memory map by default.
@@ -73,6 +76,14 @@ def test_Opener_various(): | |||
with Opener(input, 'rb') as fobj: | |||
message_back = fobj.read() | |||
assert_equal(message, message_back) | |||
if input is sobj: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit weird to have if input == sobj
above and is sobj
here, even though they probably have the same truth conditions here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - good point changed.
Anyone have a look at this, the next-to-last PR before release?
This looks reasonable to me, but someone else more experienced with the code should probably take a look. |
From comment by Eric L.
Last call for review. I will merge later today unless I hear otherwise. |
MRG: expanding, rethinking mmap'ing Expanding the tests for the bugfix suggested by @MichielCottaar Work out the previous logic for file mapping broken for a long time by using Openers.
MRG: expanding, rethinking mmap'ing Expanding the tests for the bugfix suggested by @MichielCottaar Work out the previous logic for file mapping broken for a long time by using Openers.
Expanding the tests for the bugfix suggested by @MichielCottaar
Trying to work out the previous logic broken for a long time by using Openers.