This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author wrobell
Recipients eckhardt, jbeezley, loewis, nadeem.vawda, pitrou, rosslagerwall, saa, vstinner, wrobell
Date 2011-02-10.09:43:31
SpamBayes Score 3.199e-10
Marked as misclassified No
Message-id <>
> > will this patch support off_t for "mmap.resize" as well?
> > ftruncate uses off_t for the length of a file as well.

> No, it doesn't because resize() resizes the amount mmapped in memory
> which can't be more than ssize_t anyway. However, resizing does work on
> a 12GiB file with a large offset, e.g. 6GiB.

i am bit lost. ftruncate is used to enlarge the file, isn't it?

please consider the script:

-- ---
import mmap

f = open('test.x', 'w+b')
f.write(b'\x00' * 10)

fm = mmap.mmap(f.fileno(), 0)
fm.resize(5 * 1024 ** 3)


the script above resizes file from 10 bytes
to 5 * 1024 ** 3 bytes with mmap.resize (but
not 5 * 1024 ** 3 + 10!)

now, on 32-bit linux (with off_t):

$ python3
Traceback (most recent call last):
  File "", line 8, in <module>
    fm.resize(5 * 1024 ** 3)
OverflowError: Python int too large to convert to C ssize_t

above script works perfectly on 64-bit version of linux
with just 4GB of RAM.

maybe i do not understand some magic here, but clearly one
can mmap.resize to a file size much beyond the amount of memory.
Date User Action Args
2011-02-10 09:43:32wrobellsetrecipients: + wrobell, loewis, pitrou, vstinner, nadeem.vawda, eckhardt, saa, rosslagerwall, jbeezley
2011-02-10 09:43:32wrobellsetmessageid: <>
2011-02-10 09:43:31wrobelllinkissue4681 messages
2011-02-10 09:43:31wrobellcreate