<!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>MemoryView objects — 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="Concrete Objects Layer" href="concrete.html" /> <link rel="next" title="Weak Reference Objects" href="weakref.html" /> <link rel="prev" title="Slice Objects" href="slice.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="weakref.html" title="Weak Reference Objects" accesskey="N">next</a> |</li> <li class="right" > <a href="slice.html" title="Slice Objects" 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> »</li> <li><a href="index.html" >Python/C API Reference Manual</a> »</li> <li><a href="concrete.html" accesskey="U">Concrete Objects Layer</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <span class="target" id="memoryview-objects"></span><div class="section" id="index-0"> <span id="id1"></span><h1>MemoryView objects<a class="headerlink" href="#index-0" title="Permalink to this headline">¶</a></h1> <p>A <a class="reference internal" href="../library/stdtypes.html#memoryview" title="memoryview"><tt class="xref py py-class docutils literal"><span class="pre">memoryview</span></tt></a> object exposes the C level <a class="reference internal" href="buffer.html#bufferobjects"><em>buffer interface</em></a> as a Python object which can then be passed around like any other object.</p> <dl class="function"> <dt id="PyMemoryView_FromObject"> <a class="reference internal" href="structures.html#PyObject" title="PyObject">PyObject</a> *<tt class="descname">PyMemoryView_FromObject</tt><big>(</big><a class="reference internal" href="structures.html#PyObject" title="PyObject">PyObject</a><em> *obj</em><big>)</big><a class="headerlink" href="#PyMemoryView_FromObject" title="Permalink to this definition">¶</a></dt> <dd><p>Create a memoryview object from an object that provides the buffer interface. If <em>obj</em> supports writable buffer exports, the memoryview object will be readable and writable, other it will be read-only.</p> </dd></dl> <dl class="function"> <dt id="PyMemoryView_FromBuffer"> <a class="reference internal" href="structures.html#PyObject" title="PyObject">PyObject</a> *<tt class="descname">PyMemoryView_FromBuffer</tt><big>(</big><a class="reference internal" href="buffer.html#Py_buffer" title="Py_buffer">Py_buffer</a><em> *view</em><big>)</big><a class="headerlink" href="#PyMemoryView_FromBuffer" title="Permalink to this definition">¶</a></dt> <dd><p>Create a memoryview object wrapping the given buffer structure <em>view</em>. The memoryview object then owns the buffer represented by <em>view</em>, which means you shouldn’t try to call <a class="reference internal" href="buffer.html#PyBuffer_Release" title="PyBuffer_Release"><tt class="xref c c-func docutils literal"><span class="pre">PyBuffer_Release()</span></tt></a> yourself: it will be done on deallocation of the memoryview object.</p> </dd></dl> <dl class="function"> <dt id="PyMemoryView_GetContiguous"> <a class="reference internal" href="structures.html#PyObject" title="PyObject">PyObject</a> *<tt class="descname">PyMemoryView_GetContiguous</tt><big>(</big><a class="reference internal" href="structures.html#PyObject" title="PyObject">PyObject</a><em> *obj</em>, int<em> buffertype</em>, char<em> order</em><big>)</big><a class="headerlink" href="#PyMemoryView_GetContiguous" title="Permalink to this definition">¶</a></dt> <dd><p>Create a memoryview object to a contiguous chunk of memory (in either ‘C’ or ‘F’ortran <em>order</em>) from an object that defines the buffer interface. If memory is contiguous, the memoryview object points to the original memory. Otherwise copy is made and the memoryview points to a new bytes object.</p> </dd></dl> <dl class="function"> <dt id="PyMemoryView_Check"> int <tt class="descname">PyMemoryView_Check</tt><big>(</big><a class="reference internal" href="structures.html#PyObject" title="PyObject">PyObject</a><em> *obj</em><big>)</big><a class="headerlink" href="#PyMemoryView_Check" title="Permalink to this definition">¶</a></dt> <dd><p>Return true if the object <em>obj</em> is a memoryview object. It is not currently allowed to create subclasses of <a class="reference internal" href="../library/stdtypes.html#memoryview" title="memoryview"><tt class="xref py py-class docutils literal"><span class="pre">memoryview</span></tt></a>.</p> </dd></dl> <dl class="function"> <dt id="PyMemoryView_GET_BUFFER"> <a class="reference internal" href="buffer.html#Py_buffer" title="Py_buffer">Py_buffer</a> *<tt class="descname">PyMemoryView_GET_BUFFER</tt><big>(</big><a class="reference internal" href="structures.html#PyObject" title="PyObject">PyObject</a><em> *obj</em><big>)</big><a class="headerlink" href="#PyMemoryView_GET_BUFFER" title="Permalink to this definition">¶</a></dt> <dd><p>Return a pointer to the buffer structure wrapped by the given memoryview object. The object <strong>must</strong> be a memoryview instance; this macro doesn’t check its type, you must do it yourself or you will risk crashes.</p> </dd></dl> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h4>Previous topic</h4> <p class="topless"><a href="slice.html" title="previous chapter">Slice Objects</a></p> <h4>Next topic</h4> <p class="topless"><a href="weakref.html" title="next chapter">Weak Reference Objects</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/c-api/memoryview.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="weakref.html" title="Weak Reference Objects" >next</a> |</li> <li class="right" > <a href="slice.html" title="Slice Objects" >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> »</li> <li><a href="index.html" >Python/C API Reference Manual</a> »</li> <li><a href="concrete.html" >Concrete Objects Layer</a> »</li> </ul> </div> <div class="footer"> © <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>