MMAP MODULE: This implementation of mmap contains all the functions that are present in the Cpython implementation. However there are some notable differences : (I) CONSTRUCTOR 1.Both the Windows and Unix versions of the constructor take a file object as the first argument instead of the fileno. 2.The Windows version of the mmap constructor does not support the tagname parameter. 3.The Unix version of the constructor does not support the following: (a)flags = 'MAP_DENYWRITE', 'MAP_EXECUTABLE' (b)prot = 'PROT_EXEC' (II) FLUSH function This implementation does not support flushing a part of the mapped buffer. Even if a chunk of the buffer is requested to be flushed ,the entire buffer will be flushed. (III) CLOSE function This function is supported , however the implementation makes use of a Sun specific package called sun.misc.Cleaner. RATIONALE FOR THE ABOVE DISCREPANCIES: (I) 1. In java to memory map a file the map function in the FileChannel class is used.In Cpython once a file has been memory mapped even if the file is closed the mmap can still be accessed and all the operations can be performed on it.To do this the mmap implementation in CPython creates a duplicate of the file descriptor so that even if the file is closed we can still query the file size,truncate the file etc.(in java ,can only be done with a FileChannel instance) using the duplicate file descriptor. So in jython if we use fileno as first parameter we effectively get a instance of RawIoObject from which we can derive the channel,however the channel cannot be duplicated since there seems to be no way of duplicating a file channel in java.In such a case it is impossible to perform the aforementioned file operations when the file is closed.Another way would be to open the file again to get another channel to it.But there is no way to derive the name of the file from RawIoObject instance. Hence a file object is used instead from which we derive filename and open a separate channel to the file. 2. In java ,the FileChannel map() function does not support specifying the tagname for Windows environment 3. Same reason as 2. (II) Same reason as (I)(2,3) (III) While java provides support for mapping a file there is no support for unmapping it. This is a RFE that has been reported for java. So I have used a widely circulated workaround. However there are other workarounds also like using Runtime.exec() to invoke System.gc(). However while testing the patch on Windows Vista this was the only workaround that seemed to work. Comments: 1.The test file has been taken from CPython. It has been modified in two ways: (a)The mmap constructor takes file object as parameter not fileno (b)The os.platform function has been replaced with javashell._getOsType() in order to determine the underlying os. This is because the former returns the platform as "java" 2.To make a mmap behave like a string this implementation of PyMmap extends the PyString class.A separate string is maintained along with the mapped buffer and the former is modified whenever the latter is changed.(Not sure whether this is the right way to do it....but it serves the purpose).Not extending the PyString class leads to errors in the test file where a mmap object is passed to the re.search() function since re.search() checks whether the argument passed to it is an instance of PyString. 3.This is actually a doubt.There seems to be a lack of clarity regarding how objects in jython can be made to expose the buffer interface . This implementation of mmap does not explicitly provide the buffer interface.