can somebody please explain how does 0 influence mmap in python in this case:
mmap.mmap(0 , 256, "some tag")
I thought that I always need to transfer file descriptor rather than 0, so why zero?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From reading CPython 2.7 source code, it seems that on Windows, specifying
fileno = 0has the same effect as specifyingfileno = -1, where the latter means “map anonymous memory”.Only
-1is accepted on Unix: on my 64-bit Ubuntu box with Python 2.6.5,mmap.mmap(0, 256)fails witherrno=19 (No such device)andmmap.mmap(-1, 256)works fine.Bottom line:
fileno = 0is a non-portable Windows-only variant offileno = -1. It may get deprecated (there’s even a commented-out warning in the code to that effect).P.S. The CPython source file in question is
Modules/mmapmodule.c.