Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > contrib-backports > by-pkgid > 3ba3bd1608c672ba2129b098a48e9e4d > files > 738

python3-docs-3.2.2-3mdv2010.2.noarch.rpm



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>16.5. mmap — Memory-mapped file support &mdash; Python v3.2.2 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '3.2.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python v3.2.2 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="top" title="Python v3.2.2 documentation" href="../index.html" />
    <link rel="up" title="16. Optional Operating System Services" href="someos.html" />
    <link rel="next" title="16.6. readline — GNU readline interface" href="readline.html" />
    <link rel="prev" title="16.4. concurrent.futures — Launching parallel tasks" href="concurrent.futures.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
 

  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="readline.html" title="16.6. readline — GNU readline interface"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="concurrent.futures.html" title="16.4. concurrent.futures — Launching parallel tasks"
             accesskey="P">previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="../index.html">Python v3.2.2 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="someos.html" accesskey="U">16. Optional Operating System Services</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-mmap">
<span id="mmap-memory-mapped-file-support"></span><h1>16.5. <a class="reference internal" href="#module-mmap" title="mmap: Interface to memory-mapped files for Unix and Windows."><tt class="xref py py-mod docutils literal"><span class="pre">mmap</span></tt></a> &#8212; Memory-mapped file support<a class="headerlink" href="#module-mmap" title="Permalink to this headline">¶</a></h1>
<p>Memory-mapped file objects behave like both <a class="reference internal" href="functions.html#bytearray" title="bytearray"><tt class="xref py py-class docutils literal"><span class="pre">bytearray</span></tt></a> and like
<a class="reference internal" href="../glossary.html#term-file-object"><em class="xref std std-term">file objects</em></a>.  You can use mmap objects in most places
where <a class="reference internal" href="functions.html#bytearray" title="bytearray"><tt class="xref py py-class docutils literal"><span class="pre">bytearray</span></tt></a> are expected; for example, you can use the <a class="reference internal" href="re.html#module-re" title="re: Regular expression operations."><tt class="xref py py-mod docutils literal"><span class="pre">re</span></tt></a>
module to search through a memory-mapped file.  You can also change a single
byte by doing <tt class="docutils literal"><span class="pre">obj[index]</span> <span class="pre">=</span> <span class="pre">97</span></tt>, or change a subsequence by assigning to a
slice: <tt class="docutils literal"><span class="pre">obj[i1:i2]</span> <span class="pre">=</span> <span class="pre">b'...'</span></tt>.  You can also read and write data starting at
the current file position, and <a class="reference internal" href="#mmap.seek" title="mmap.seek"><tt class="xref py py-meth docutils literal"><span class="pre">seek()</span></tt></a> through the file to different positions.</p>
<p>A memory-mapped file is created by the <a class="reference internal" href="#module-mmap" title="mmap: Interface to memory-mapped files for Unix and Windows."><tt class="xref py py-class docutils literal"><span class="pre">mmap</span></tt></a> constructor, which is
different on Unix and on Windows.  In either case you must provide a file
descriptor for a file opened for update. If you wish to map an existing Python
file object, use its <tt class="xref py py-meth docutils literal"><span class="pre">fileno()</span></tt> method to obtain the correct value for the
<em>fileno</em> parameter.  Otherwise, you can open the file using the
<a class="reference internal" href="os.html#os.open" title="os.open"><tt class="xref py py-func docutils literal"><span class="pre">os.open()</span></tt></a> function, which returns a file descriptor directly (the file
still needs to be closed when done).</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If you want to create a memory-mapping for a writable, buffered file, you
should <a class="reference internal" href="io.html#io.IOBase.flush" title="io.IOBase.flush"><tt class="xref py py-func docutils literal"><span class="pre">flush()</span></tt></a> the file first.  This is necessary to ensure
that local modifications to the buffers are actually available to the
mapping.</p>
</div>
<p>For both the Unix and Windows versions of the constructor, <em>access</em> may be
specified as an optional keyword parameter. <em>access</em> accepts one of three
values: <tt class="xref py py-const docutils literal"><span class="pre">ACCESS_READ</span></tt>, <tt class="xref py py-const docutils literal"><span class="pre">ACCESS_WRITE</span></tt>, or <tt class="xref py py-const docutils literal"><span class="pre">ACCESS_COPY</span></tt>
to specify read-only, write-through or copy-on-write memory respectively.
<em>access</em> can be used on both Unix and Windows.  If <em>access</em> is not specified,
Windows mmap returns a write-through mapping.  The initial memory values for
all three access types are taken from the specified file.  Assignment to an
<tt class="xref py py-const docutils literal"><span class="pre">ACCESS_READ</span></tt> memory map raises a <a class="reference internal" href="exceptions.html#TypeError" title="TypeError"><tt class="xref py py-exc docutils literal"><span class="pre">TypeError</span></tt></a> exception.
Assignment to an <tt class="xref py py-const docutils literal"><span class="pre">ACCESS_WRITE</span></tt> memory map affects both memory and the
underlying file.  Assignment to an <tt class="xref py py-const docutils literal"><span class="pre">ACCESS_COPY</span></tt> memory map affects
memory but does not update the underlying file.</p>
<p>To map anonymous memory, -1 should be passed as the fileno along with the length.</p>
<dl class="class">
<dt id="mmap.mmap">
<em class="property">class </em><tt class="descclassname">mmap.</tt><tt class="descname">mmap</tt><big>(</big><em>fileno</em>, <em>length</em>, <em>tagname=None</em>, <em>access=ACCESS_DEFAULT</em><span class="optional">[</span>, <em>offset</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#mmap.mmap" title="Permalink to this definition">¶</a></dt>
<dd><p><strong>(Windows version)</strong> Maps <em>length</em> bytes from the file specified by the
file handle <em>fileno</em>, and creates a mmap object.  If <em>length</em> is larger
than the current size of the file, the file is extended to contain <em>length</em>
bytes.  If <em>length</em> is <tt class="docutils literal"><span class="pre">0</span></tt>, the maximum length of the map is the current
size of the file, except that if the file is empty Windows raises an
exception (you cannot create an empty mapping on Windows).</p>
<p><em>tagname</em>, if specified and not <tt class="xref docutils literal"><span class="pre">None</span></tt>, is a string giving a tag name for
the mapping.  Windows allows you to have many different mappings against
the same file.  If you specify the name of an existing tag, that tag is
opened, otherwise a new tag of this name is created.  If this parameter is
omitted or <tt class="xref docutils literal"><span class="pre">None</span></tt>, the mapping is created without a name.  Avoiding the
use of the tag parameter will assist in keeping your code portable between
Unix and Windows.</p>
<p><em>offset</em> may be specified as a non-negative integer offset. mmap references
will be relative to the offset from the beginning of the file. <em>offset</em>
defaults to 0.  <em>offset</em> must be a multiple of the ALLOCATIONGRANULARITY.</p>
</dd></dl>

<dl class="class">
<dt>
<em class="property">class </em><tt class="descclassname">mmap.</tt><tt class="descname">mmap</tt><big>(</big><em>fileno</em>, <em>length</em>, <em>flags=MAP_SHARED</em>, <em>prot=PROT_WRITE|PROT_READ</em>, <em>access=ACCESS_DEFAULT</em><span class="optional">[</span>, <em>offset</em><span class="optional">]</span><big>)</big></dt>
<dd><p><strong>(Unix version)</strong> Maps <em>length</em> bytes from the file specified by the file
descriptor <em>fileno</em>, and returns a mmap object.  If <em>length</em> is <tt class="docutils literal"><span class="pre">0</span></tt>, the
maximum length of the map will be the current size of the file when
<a class="reference internal" href="#module-mmap" title="mmap: Interface to memory-mapped files for Unix and Windows."><tt class="xref py py-class docutils literal"><span class="pre">mmap</span></tt></a> is called.</p>
<p><em>flags</em> specifies the nature of the mapping. <tt class="xref py py-const docutils literal"><span class="pre">MAP_PRIVATE</span></tt> creates a
private copy-on-write mapping, so changes to the contents of the mmap
object will be private to this process, and <tt class="xref py py-const docutils literal"><span class="pre">MAP_SHARED</span></tt> creates a
mapping that&#8217;s shared with all other processes mapping the same areas of
the file.  The default value is <tt class="xref py py-const docutils literal"><span class="pre">MAP_SHARED</span></tt>.</p>
<p><em>prot</em>, if specified, gives the desired memory protection; the two most
useful values are <tt class="xref py py-const docutils literal"><span class="pre">PROT_READ</span></tt> and <tt class="xref py py-const docutils literal"><span class="pre">PROT_WRITE</span></tt>, to specify
that the pages may be read or written.  <em>prot</em> defaults to
<tt class="xref py py-const docutils literal"><span class="pre">PROT_READ</span> <span class="pre">|</span> <span class="pre">PROT_WRITE</span></tt>.</p>
<p><em>access</em> may be specified in lieu of <em>flags</em> and <em>prot</em> as an optional
keyword parameter.  It is an error to specify both <em>flags</em>, <em>prot</em> and
<em>access</em>.  See the description of <em>access</em> above for information on how to
use this parameter.</p>
<p><em>offset</em> may be specified as a non-negative integer offset. mmap references
will be relative to the offset from the beginning of the file. <em>offset</em>
defaults to 0.  <em>offset</em> must be a multiple of the PAGESIZE or
ALLOCATIONGRANULARITY.</p>
<p>To ensure validity of the created memory mapping the file specified
by the descriptor <em>fileno</em> is internally automatically synchronized
with physical backing store on Mac OS X and OpenVMS.</p>
<p>This example shows a simple way of using <a class="reference internal" href="#module-mmap" title="mmap: Interface to memory-mapped files for Unix and Windows."><tt class="xref py py-class docutils literal"><span class="pre">mmap</span></tt></a>:</p>
<div class="highlight-python3"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">mmap</span>

<span class="c"># write a simple example file</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s">&quot;hello.txt&quot;</span><span class="p">,</span> <span class="s">&quot;wb&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
    <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">b</span><span class="s">&quot;Hello Python!</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">)</span>

<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s">&quot;hello.txt&quot;</span><span class="p">,</span> <span class="s">&quot;r+b&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
    <span class="c"># memory-map the file, size 0 means whole file</span>
    <span class="nb">map</span> <span class="o">=</span> <span class="n">mmap</span><span class="o">.</span><span class="n">mmap</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="n">fileno</span><span class="p">(),</span> <span class="mi">0</span><span class="p">)</span>
    <span class="c"># read content via standard file methods</span>
    <span class="nb">print</span><span class="p">(</span><span class="nb">map</span><span class="o">.</span><span class="n">readline</span><span class="p">())</span>  <span class="c"># prints b&quot;Hello Python!\n&quot;</span>
    <span class="c"># read content via slice notation</span>
    <span class="nb">print</span><span class="p">(</span><span class="nb">map</span><span class="p">[:</span><span class="mi">5</span><span class="p">])</span>  <span class="c"># prints b&quot;Hello&quot;</span>
    <span class="c"># update content using slice notation;</span>
    <span class="c"># note that new content must have same size</span>
    <span class="nb">map</span><span class="p">[</span><span class="mi">6</span><span class="p">:]</span> <span class="o">=</span> <span class="n">b</span><span class="s">&quot; world!</span><span class="se">\n</span><span class="s">&quot;</span>
    <span class="c"># ... and read again using standard file methods</span>
    <span class="nb">map</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
    <span class="nb">print</span><span class="p">(</span><span class="nb">map</span><span class="o">.</span><span class="n">readline</span><span class="p">())</span>  <span class="c"># prints b&quot;Hello  world!\n&quot;</span>
    <span class="c"># close the map</span>
    <span class="nb">map</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
</pre></div>
</div>
<p><a class="reference internal" href="#module-mmap" title="mmap: Interface to memory-mapped files for Unix and Windows."><tt class="xref py py-class docutils literal"><span class="pre">mmap</span></tt></a> can also be used as a context manager in a <a class="reference internal" href="../reference/compound_stmts.html#with"><tt class="xref std std-keyword docutils literal"><span class="pre">with</span></tt></a>
statement.:</p>
<div class="highlight-python3"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">mmap</span>

<span class="k">with</span> <span class="n">mmap</span><span class="o">.</span><span class="n">mmap</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">13</span><span class="p">)</span> <span class="k">as</span> <span class="nb">map</span><span class="p">:</span>
    <span class="nb">map</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">&quot;Hello world!&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p class="versionadded">
<span class="versionmodified">New in version 3.2: </span>Context manager support.</p>
<p>The next example demonstrates how to create an anonymous map and exchange
data between the parent and child processes:</p>
<div class="highlight-python3"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">mmap</span>
<span class="kn">import</span> <span class="nn">os</span>

<span class="nb">map</span> <span class="o">=</span> <span class="n">mmap</span><span class="o">.</span><span class="n">mmap</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">13</span><span class="p">)</span>
<span class="nb">map</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">b</span><span class="s">&quot;Hello world!&quot;</span><span class="p">)</span>

<span class="n">pid</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">fork</span><span class="p">()</span>

<span class="k">if</span> <span class="n">pid</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> <span class="c"># In a child process</span>
    <span class="nb">map</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
    <span class="nb">print</span><span class="p">(</span><span class="nb">map</span><span class="o">.</span><span class="n">readline</span><span class="p">())</span>

    <span class="nb">map</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
</pre></div>
</div>
<p>Memory-mapped file objects support the following methods:</p>
<dl class="method">
<dt id="mmap.close">
<tt class="descclassname">mmap.</tt><tt class="descname">close</tt><big>(</big><big>)</big><a class="headerlink" href="#mmap.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Close the file.  Subsequent calls to other methods of the object will
result in an exception being raised.</p>
</dd></dl>

<dl class="attribute">
<dt id="mmap.closed">
<tt class="descclassname">mmap.</tt><tt class="descname">closed</tt><a class="headerlink" href="#mmap.closed" title="Permalink to this definition">¶</a></dt>
<dd><p>True if the file is closed.</p>
<p class="versionadded">
<span class="versionmodified">New in version 3.2.</span></p>
</dd></dl>

<dl class="method">
<dt id="mmap.find">
<tt class="descclassname">mmap.</tt><tt class="descname">find</tt><big>(</big><em>sub</em><span class="optional">[</span>, <em>start</em><span class="optional">[</span>, <em>end</em><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#mmap.find" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the lowest index in the object where the subsequence <em>sub</em> is
found, such that <em>sub</em> is contained in the range [<em>start</em>, <em>end</em>].
Optional arguments <em>start</em> and <em>end</em> are interpreted as in slice notation.
Returns <tt class="docutils literal"><span class="pre">-1</span></tt> on failure.</p>
</dd></dl>

<dl class="method">
<dt id="mmap.flush">
<tt class="descclassname">mmap.</tt><tt class="descname">flush</tt><big>(</big><span class="optional">[</span><em>offset</em><span class="optional">[</span>, <em>size</em><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#mmap.flush" title="Permalink to this definition">¶</a></dt>
<dd><p>Flushes changes made to the in-memory copy of a file back to disk. Without
use of this call there is no guarantee that changes are written back before
the object is destroyed.  If <em>offset</em> and <em>size</em> are specified, only
changes to the given range of bytes will be flushed to disk; otherwise, the
whole extent of the mapping is flushed.</p>
<p><strong>(Windows version)</strong> A nonzero value returned indicates success; zero
indicates failure.</p>
<p><strong>(Unix version)</strong> A zero value is returned to indicate success. An
exception is raised when the call failed.</p>
</dd></dl>

<dl class="method">
<dt id="mmap.move">
<tt class="descclassname">mmap.</tt><tt class="descname">move</tt><big>(</big><em>dest</em>, <em>src</em>, <em>count</em><big>)</big><a class="headerlink" href="#mmap.move" title="Permalink to this definition">¶</a></dt>
<dd><p>Copy the <em>count</em> bytes starting at offset <em>src</em> to the destination index
<em>dest</em>.  If the mmap was created with <tt class="xref py py-const docutils literal"><span class="pre">ACCESS_READ</span></tt>, then calls to
move will raise a <a class="reference internal" href="exceptions.html#TypeError" title="TypeError"><tt class="xref py py-exc docutils literal"><span class="pre">TypeError</span></tt></a> exception.</p>
</dd></dl>

<dl class="method">
<dt id="mmap.read">
<tt class="descclassname">mmap.</tt><tt class="descname">read</tt><big>(</big><em>num</em><big>)</big><a class="headerlink" href="#mmap.read" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a <a class="reference internal" href="functions.html#bytes" title="bytes"><tt class="xref py py-class docutils literal"><span class="pre">bytes</span></tt></a> containing up to <em>num</em> bytes starting from the
current file position; the file position is updated to point after the
bytes that were returned.</p>
</dd></dl>

<dl class="method">
<dt id="mmap.read_byte">
<tt class="descclassname">mmap.</tt><tt class="descname">read_byte</tt><big>(</big><big>)</big><a class="headerlink" href="#mmap.read_byte" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a byte at the current file position as an integer, and advances
the file position by 1.</p>
</dd></dl>

<dl class="method">
<dt id="mmap.readline">
<tt class="descclassname">mmap.</tt><tt class="descname">readline</tt><big>(</big><big>)</big><a class="headerlink" href="#mmap.readline" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a single line, starting at the current file position and up to the
next newline.</p>
</dd></dl>

<dl class="method">
<dt id="mmap.resize">
<tt class="descclassname">mmap.</tt><tt class="descname">resize</tt><big>(</big><em>newsize</em><big>)</big><a class="headerlink" href="#mmap.resize" title="Permalink to this definition">¶</a></dt>
<dd><p>Resizes the map and the underlying file, if any. If the mmap was created
with <tt class="xref py py-const docutils literal"><span class="pre">ACCESS_READ</span></tt> or <tt class="xref py py-const docutils literal"><span class="pre">ACCESS_COPY</span></tt>, resizing the map will
raise a <a class="reference internal" href="exceptions.html#TypeError" title="TypeError"><tt class="xref py py-exc docutils literal"><span class="pre">TypeError</span></tt></a> exception.</p>
</dd></dl>

<dl class="method">
<dt id="mmap.rfind">
<tt class="descclassname">mmap.</tt><tt class="descname">rfind</tt><big>(</big><em>sub</em><span class="optional">[</span>, <em>start</em><span class="optional">[</span>, <em>end</em><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#mmap.rfind" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the highest index in the object where the subsequence <em>sub</em> is
found, such that <em>sub</em> is contained in the range [<em>start</em>, <em>end</em>].
Optional arguments <em>start</em> and <em>end</em> are interpreted as in slice notation.
Returns <tt class="docutils literal"><span class="pre">-1</span></tt> on failure.</p>
</dd></dl>

<dl class="method">
<dt id="mmap.seek">
<tt class="descclassname">mmap.</tt><tt class="descname">seek</tt><big>(</big><em>pos</em><span class="optional">[</span>, <em>whence</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#mmap.seek" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the file&#8217;s current position.  <em>whence</em> argument is optional and
defaults to <tt class="docutils literal"><span class="pre">os.SEEK_SET</span></tt> or <tt class="docutils literal"><span class="pre">0</span></tt> (absolute file positioning); other
values are <tt class="docutils literal"><span class="pre">os.SEEK_CUR</span></tt> or <tt class="docutils literal"><span class="pre">1</span></tt> (seek relative to the current
position) and <tt class="docutils literal"><span class="pre">os.SEEK_END</span></tt> or <tt class="docutils literal"><span class="pre">2</span></tt> (seek relative to the file&#8217;s end).</p>
</dd></dl>

<dl class="method">
<dt id="mmap.size">
<tt class="descclassname">mmap.</tt><tt class="descname">size</tt><big>(</big><big>)</big><a class="headerlink" href="#mmap.size" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the length of the file, which can be larger than the size of the
memory-mapped area.</p>
</dd></dl>

<dl class="method">
<dt id="mmap.tell">
<tt class="descclassname">mmap.</tt><tt class="descname">tell</tt><big>(</big><big>)</big><a class="headerlink" href="#mmap.tell" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the current position of the file pointer.</p>
</dd></dl>

<dl class="method">
<dt id="mmap.write">
<tt class="descclassname">mmap.</tt><tt class="descname">write</tt><big>(</big><em>bytes</em><big>)</big><a class="headerlink" href="#mmap.write" title="Permalink to this definition">¶</a></dt>
<dd><p>Write the bytes in <em>bytes</em> into memory at the current position of the
file pointer; the file position is updated to point after the bytes that
were written. If the mmap was created with <tt class="xref py py-const docutils literal"><span class="pre">ACCESS_READ</span></tt>, then
writing to it will raise a <a class="reference internal" href="exceptions.html#TypeError" title="TypeError"><tt class="xref py py-exc docutils literal"><span class="pre">TypeError</span></tt></a> exception.</p>
</dd></dl>

<dl class="method">
<dt id="mmap.write_byte">
<tt class="descclassname">mmap.</tt><tt class="descname">write_byte</tt><big>(</big><em>byte</em><big>)</big><a class="headerlink" href="#mmap.write_byte" title="Permalink to this definition">¶</a></dt>
<dd><p>Write the the integer <em>byte</em> into memory at the current
position of the file pointer; the file position is advanced by <tt class="docutils literal"><span class="pre">1</span></tt>. If
the mmap was created with <tt class="xref py py-const docutils literal"><span class="pre">ACCESS_READ</span></tt>, then writing to it will
raise a <a class="reference internal" href="exceptions.html#TypeError" title="TypeError"><tt class="xref py py-exc docutils literal"><span class="pre">TypeError</span></tt></a> exception.</p>
</dd></dl>

</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="concurrent.futures.html"
                        title="previous chapter">16.4. <tt class="docutils literal docutils literal"><span class="pre">concurrent.futures</span></tt> &#8212; Launching parallel tasks</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="readline.html"
                        title="next chapter">16.6. <tt class="docutils literal"><span class="pre">readline</span></tt> &#8212; GNU readline interface</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
  <li><a href="../bugs.html">Report a Bug</a></li>
  <li><a href="../_sources/library/mmap.txt"
         rel="nofollow">Show Source</a></li>
</ul>

<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="readline.html" title="16.6. readline — GNU readline interface"
             >next</a> |</li>
        <li class="right" >
          <a href="concurrent.futures.html" title="16.4. concurrent.futures — Launching parallel tasks"
             >previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="../index.html">Python v3.2.2 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="someos.html" >16. Optional Operating System Services</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 1990-2011, Python Software Foundation.
    <br />
    The Python Software Foundation is a non-profit corporation.  
    <a href="http://www.python.org/psf/donations/">Please donate.</a>
    <br />
    Last updated on Sep 04, 2011.
    <a href="../bugs.html">Found a bug</a>?
    <br />
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
    </div>

  </body>
</html>