using mmap on large (> 2 Gig) files

Donn Cave donn at
Tue Oct 24 18:22:51 CEST 2006

In article <1161648415.830523.225520 at>,
 "sturlamolden" <sturlamolden at> wrote:
> It seems that Python does take a length argument, but not an offset
> argument (unlike the Windows' CreateFileMapping/MapViewOfFile and UNIX'
> mmap), so you always map from the beginning of the file. Of course if
> you have ever worked with memory mapping files in C, you will probably
> have experienced that mapping a large file from beginning to end is a
> major slowdown.

I certainly have not experienced that.  mmap itself takes nearly
no time, there should be no I/O.  Access to mapped pages may
require I/O, but there is no way around that in any case.

> I haven't looked at the source, but I'd be surprised if Python actually
> maps the file into the process image when mmap is called. I believe
> Python is not memory mapping at all; rather, it just opens a file in
> the file system and uses fseek to move around.

Wow, you're sure a wizard!  Most people would need to look before
making statements like that.

   Donn Cave, donn at

More information about the Python-list mailing list