1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
<html xmlns="http://www.w3.org/1999/xhtml">
7
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9
<title>Cell Objects — Python 2.7.12 documentation</title>
11
<link rel="stylesheet" href="../_static/classic.css" type="text/css" />
12
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
14
<script type="text/javascript">
15
var DOCUMENTATION_OPTIONS = {
18
COLLAPSE_INDEX: false,
23
<script type="text/javascript" src="../_static/jquery.js"></script>
24
<script type="text/javascript" src="../_static/underscore.js"></script>
25
<script type="text/javascript" src="../_static/doctools.js"></script>
26
<script type="text/javascript" src="../_static/sidebar.js"></script>
27
<link rel="search" type="application/opensearchdescription+xml"
28
title="Search within Python 2.7.12 documentation"
29
href="../_static/opensearch.xml"/>
30
<link rel="author" title="About these documents" href="../about.html" />
31
<link rel="copyright" title="Copyright" href="../copyright.html" />
32
<link rel="top" title="Python 2.7.12 documentation" href="../contents.html" />
33
<link rel="up" title="Concrete Objects Layer" href="concrete.html" />
34
<link rel="next" title="Generator Objects" href="gen.html" />
35
<link rel="prev" title="CObjects" href="cobject.html" />
36
<link rel="shortcut icon" type="image/png" href="../_static/py.png" />
37
<script type="text/javascript" src="../_static/copybutton.js"></script>
38
<script type="text/javascript" src="../_static/version_switch.js"></script>
43
<body role="document">
44
<div class="related" role="navigation" aria-label="related navigation">
47
<li class="right" style="margin-right: 10px">
48
<a href="../genindex.html" title="General Index"
49
accesskey="I">index</a></li>
51
<a href="../py-modindex.html" title="Python Module Index"
54
<a href="gen.html" title="Generator Objects"
55
accesskey="N">next</a> |</li>
57
<a href="cobject.html" title="CObjects"
58
accesskey="P">previous</a> |</li>
59
<li><img src="../_static/py.png" alt=""
60
style="vertical-align: middle; margin-top: -1px"/></li>
61
<li><a href="https://www.python.org/">Python</a> »</li>
63
<span class="version_switcher_placeholder">2.7.12</span>
64
<a href="../index.html">Documentation</a> »
67
<li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> »</li>
68
<li class="nav-item nav-item-2"><a href="concrete.html" accesskey="U">Concrete Objects Layer</a> »</li>
72
<div class="document">
73
<div class="documentwrapper">
74
<div class="bodywrapper">
75
<div class="body" role="main">
77
<div class="section" id="cell-objects">
78
<span id="id1"></span><h1>Cell Objects<a class="headerlink" href="#cell-objects" title="Permalink to this headline">¶</a></h1>
79
<p>“Cell” objects are used to implement variables referenced by multiple scopes.
80
For each such variable, a cell object is created to store the value; the local
81
variables of each stack frame that references the value contains a reference to
82
the cells from outer scopes which also use that variable. When the value is
83
accessed, the value contained in the cell is used instead of the cell object
84
itself. This de-referencing of the cell object requires support from the
85
generated byte-code; these are not automatically de-referenced when accessed.
86
Cell objects are not likely to be useful elsewhere.</p>
88
<dt id="c.PyCellObject">
89
<code class="descname">PyCellObject</code><a class="headerlink" href="#c.PyCellObject" title="Permalink to this definition">¶</a></dt>
90
<dd><p>The C structure used for cell objects.</p>
94
<dt id="c.PyCell_Type">
95
<a class="reference internal" href="type.html#c.PyTypeObject" title="PyTypeObject">PyTypeObject</a> <code class="descname">PyCell_Type</code><a class="headerlink" href="#c.PyCell_Type" title="Permalink to this definition">¶</a></dt>
96
<dd><p>The type object corresponding to cell objects.</p>
100
<dt id="c.PyCell_Check">
101
int <code class="descname">PyCell_Check</code><span class="sig-paren">(</span>ob<span class="sig-paren">)</span><a class="headerlink" href="#c.PyCell_Check" title="Permalink to this definition">¶</a></dt>
102
<dd><p>Return true if <em>ob</em> is a cell object; <em>ob</em> must not be <em>NULL</em>.</p>
105
<dl class="function">
106
<dt id="c.PyCell_New">
107
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PyCell_New</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *ob</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCell_New" title="Permalink to this definition">¶</a></dt>
108
<dd><em class="refcount">Return value: New reference.</em><p>Create and return a new cell object containing the value <em>ob</em>. The parameter may
109
be <em>NULL</em>.</p>
112
<dl class="function">
113
<dt id="c.PyCell_Get">
114
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PyCell_Get</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *cell</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCell_Get" title="Permalink to this definition">¶</a></dt>
115
<dd><em class="refcount">Return value: New reference.</em><p>Return the contents of the cell <em>cell</em>.</p>
118
<dl class="function">
119
<dt id="c.PyCell_GET">
120
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="descname">PyCell_GET</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *cell</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCell_GET" title="Permalink to this definition">¶</a></dt>
121
<dd><em class="refcount">Return value: Borrowed reference.</em><p>Return the contents of the cell <em>cell</em>, but without checking that <em>cell</em> is
122
non-<em>NULL</em> and a cell object.</p>
125
<dl class="function">
126
<dt id="c.PyCell_Set">
127
int <code class="descname">PyCell_Set</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *cell</em>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *value</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCell_Set" title="Permalink to this definition">¶</a></dt>
128
<dd><p>Set the contents of the cell object <em>cell</em> to <em>value</em>. This releases the
129
reference to any current content of the cell. <em>value</em> may be <em>NULL</em>. <em>cell</em>
130
must be non-<em>NULL</em>; if it is not a cell object, <code class="docutils literal"><span class="pre">-1</span></code> will be returned. On
131
success, <code class="docutils literal"><span class="pre">0</span></code> will be returned.</p>
134
<dl class="function">
135
<dt id="c.PyCell_SET">
136
void <code class="descname">PyCell_SET</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *cell</em>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *value</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCell_SET" title="Permalink to this definition">¶</a></dt>
137
<dd><p>Sets the value of the cell object <em>cell</em> to <em>value</em>. No reference counts are
138
adjusted, and no checks are made for safety; <em>cell</em> must be non-<em>NULL</em> and must
139
be a cell object.</p>
148
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
149
<div class="sphinxsidebarwrapper">
150
<h4>Previous topic</h4>
151
<p class="topless"><a href="cobject.html"
152
title="previous chapter">CObjects</a></p>
154
<p class="topless"><a href="gen.html"
155
title="next chapter">Generator Objects</a></p>
157
<ul class="this-page-menu">
158
<li><a href="../bugs.html">Report a Bug</a></li>
159
<li><a href="../_sources/c-api/cell.txt"
160
rel="nofollow">Show Source</a></li>
163
<div id="searchbox" style="display: none" role="search">
164
<h3>Quick search</h3>
165
<form class="search" action="../search.html" method="get">
166
<input type="text" name="q" />
167
<input type="submit" value="Go" />
168
<input type="hidden" name="check_keywords" value="yes" />
169
<input type="hidden" name="area" value="default" />
171
<p class="searchtip" style="font-size: 90%">
172
Enter search terms or a module, class or function name.
175
<script type="text/javascript">$('#searchbox').show(0);</script>
178
<div class="clearer"></div>
180
<div class="related" role="navigation" aria-label="related navigation">
183
<li class="right" style="margin-right: 10px">
184
<a href="../genindex.html" title="General Index"
187
<a href="../py-modindex.html" title="Python Module Index"
190
<a href="gen.html" title="Generator Objects"
193
<a href="cobject.html" title="CObjects"
195
<li><img src="../_static/py.png" alt=""
196
style="vertical-align: middle; margin-top: -1px"/></li>
197
<li><a href="https://www.python.org/">Python</a> »</li>
199
<span class="version_switcher_placeholder">2.7.12</span>
200
<a href="../index.html">Documentation</a> »
203
<li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> »</li>
204
<li class="nav-item nav-item-2"><a href="concrete.html" >Concrete Objects Layer</a> »</li>
208
© <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
210
The Python Software Foundation is a non-profit corporation.
211
<a href="https://www.python.org/psf/donations/">Please donate.</a>
213
Last updated on Sep 20, 2016.
214
<a href="../bugs.html">Found a bug</a>?
216
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
b'\\ No newline at end of file'