Ross Lagerwall <rosslagerw...@gmail.com> added the comment: 32-bit computers can address up to 4GiB of memory and 64-bit computers can address much more than this. mmap() allows a file to be mapped to a location in memory - the actual amount of memory that exists doesn't matter. This is the reason why a 5GiB file can be mmaped on 64-bit but not 32-bit.
Also, python uses the ssize_t type for sequences which allows about 2GiB to be mapped on a 32-bit platform. The mmap.resize() operation as well as changing the size of the underlying file size with ftruncate(), also changes the size of the map in memory. Thus in your sample script, this resizing would need to ftruncate the file to 5GiB and then map all of it into memory which is not possible on 32-bit. I think the following might be a possible way of doing it: import mmap f = open('test.x', 'w+b') f.write(b'\x00' * 10) f.flush() fm = mmap.mmap(f.fileno(), 0) fm.close() f.truncate(5 * 1024 ** 3) # mmap only 1GiB of the 5GiB file fm = mmap.mmap(f.fileno(), 1024**3) fm.close() f.close() ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4681> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com