forked from serge-sans-paille/pythran-stories
-
Notifications
You must be signed in to change notification settings - Fork 0
/
identifier-binding-computation.html
637 lines (610 loc) · 53.1 KB
/
identifier-binding-computation.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Identifier Binding Computation</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="serge-sans-paille and other pythraners">
<!-- Le styles -->
<link rel="stylesheet" href="./theme/css/bootstrap.min.css" type="text/css" />
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
.sidebar-nav {
padding: 9px 0;
}
.tag-1 {
font-size: 13pt;
}
.tag-2 {
font-size: 10pt;
}
.tag-2 {
font-size: 8pt;
}
.tag-4 {
font-size: 6pt;
}
</style>
<link href="./theme/css/bootstrap-responsive.min.css" rel="stylesheet">
<link href="./theme/css/font-awesome.css" rel="stylesheet">
<link href="./theme/css/pygments.css" rel="stylesheet">
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Le fav and touch icons -->
<link rel="shortcut icon" href="./theme/images/favicon.ico">
<link rel="apple-touch-icon" href="./theme/images/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="./theme/images/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="./theme/images/apple-touch-icon-114x114.png">
<link href="./" type="application/atom+xml" rel="alternate" title="Pythran stories ATOM Feed" />
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="./index.html">Pythran stories </a>
<div class="nav-collapse">
<ul class="nav">
<li class="divider-vertical"></li>
<li >
<a href="./category/benchmark.html">
<i class="icon-folder-open icon-large"></i>benchmark
</a>
</li>
<li class="active">
<a href="./category/compilation.html">
<i class="icon-folder-open icon-large"></i>compilation
</a>
</li>
<li >
<a href="./category/cython.html">
<i class="icon-folder-open icon-large"></i>cython
</a>
</li>
<li >
<a href="./category/engineering.html">
<i class="icon-folder-open icon-large"></i>engineering
</a>
</li>
<li >
<a href="./category/examples.html">
<i class="icon-folder-open icon-large"></i>examples
</a>
</li>
<li >
<a href="./category/optimisation.html">
<i class="icon-folder-open icon-large"></i>optimisation
</a>
</li>
<li >
<a href="./category/release.html">
<i class="icon-folder-open icon-large"></i>release
</a>
</li>
<ul class="nav pull-right">
<li><a href="./archives.html"><i class="icon-th-list"></i>Archives</a></li>
</ul>
</ul>
<!--<p class="navbar-text pull-right">Logged in as <a href="#">username</a></p>-->
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="span9" id="content">
<section id="content">
<article>
<header>
<h1>
<a href=""
rel="bookmark"
title="Permalink to Identifier Binding Computation">
Identifier Binding Computation
</a>
</h1>
</header>
<div class="entry-content">
<div class="well">
<footer class="post-info">
<span class="label">Date</span>
<abbr class="published" title="2016-04-18T00:00:00+02:00">
<i class="icon-calendar"></i>Mon 18 April 2016
</abbr>
<span class="label">By</span>
<a href="./author/serge-sans-paille.html"><i class="icon-user"></i>serge-sans-paille</a>
<span class="label">Category</span>
<a href="./category/compilation.html"><i class="icon-folder-open"></i>compilation</a>.
</footer><!-- /.post-info --> </div>
<div class="section" id="foreword">
<h2>Foreword</h2>
<p>This is <strong>not</strong> a <a class="reference external" href="http://jupyter-notebook-beginner-guide.readthedocs.org/en/latest/what_is_jupyter.html">Jupyter notebook</a>,
but it could have been. Instead, the content of this article is mostly taken from
the <a class="reference external" href="https://docs.python.org/2/library/doctest.html">Doctest</a> of the
<tt class="docutils literal">pythran.analyses.aliases</tt> module, and the relevant unit tests in
<tt class="docutils literal">test_typing.py</tt>. So the reader still has a strong warranty that the output
described is the one she would get by running the commands herself.</p>
<p>The curious reader can verify this statement by running <tt class="docutils literal">python <span class="pre">-m</span> doctest</tt>
with Pythran in its <tt class="docutils literal">PYTHONPATH</tt> <a class="citation-reference" href="#git-version" id="id1">[git-version]</a> on the article source, which is in fact what
I did before posting it <tt class="docutils literal"><span class="pre">:-)</span></tt>.</p>
</div>
<div class="section" id="static-computation-of-identifier-binding">
<h2>Static Computation of Identifier Binding</h2>
<p>In Python, everything is a reference, from literal to objects. Assignment
creates a <em>binding</em> between a reference and an identifier, thus the following
sequence always hold:</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="nb">list</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">b</span> <span class="o">=</span> <span class="n">c</span> <span class="o">=</span> <span class="n">a</span>
<span class="gp">>>> </span><span class="n">d</span> <span class="o">=</span> <span class="n">b</span>
<span class="gp">>>> </span><span class="n">d</span> <span class="ow">is</span> <span class="n">a</span>
<span class="go">True</span>
</pre></div>
<p>In some sense, assignement creates aliasing between identifiers, as any change
made to the <em>value</em> referenced by the identifier <tt class="docutils literal">b</tt> impacts the <em>value</em>
referenced by identifer <tt class="docutils literal">c</tt> (and <tt class="docutils literal">a</tt> and <tt class="docutils literal">d</tt>):</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="gp">>>> </span><span class="nb">len</span><span class="p">(</span><span class="n">b</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">c</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">d</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span>
<span class="go">True</span>
</pre></div>
<p>In the context of Pythran, the static knowledge of the different values of an
identifier <strong>may</strong> be bound to, is critical. First there is no reason to trust
an identifier, as shown by the following code:</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">id</span> <span class="o">=</span> <span class="nb">len</span>
<span class="gp">>>> </span><span class="nb">id</span><span class="p">([</span><span class="mi">1</span><span class="p">])</span>
<span class="go">1</span>
</pre></div>
<p>Nothing prevents this to happen in Python <a class="footnote-reference" href="#id4" id="id2">[0]</a>, so Pythran takes great care in
not confusing <em>identifiers</em> and <em>values</em>. And The ill-named Alias Analysis is
the tool we use to solve this problem. In the particular case above, this
analysis tells us that the identifier <tt class="docutils literal">id</tt> in the call expression <tt class="docutils literal"><span class="pre">id([1])</span></tt>
always has the value <tt class="docutils literal">__builtin__.len</tt>. This can be used, for instance, to
state that this call has no side effect.</p>
</div>
<div class="section" id="where-is-identifier-binding-used-in-pythran">
<h2>Where is Identifier Binding Used in Pythran</h2>
<p>Identifier binding is used by all Pythran analyses that interact with function
calls, when they need to know something about the function property, or when
they want to verify that all the possibles (function) values taken by an
identifier share the same property. For instance:</p>
<blockquote>
<ol class="arabic simple">
<li>Conversion from calls with named arguments to call without named arguments, as in <tt class="docutils literal">zeros(10, dtype=int)</tt></li>
<li>Conversion from iterator to generator, e.g. turning <tt class="docutils literal">range</tt> into <tt class="docutils literal">xrange</tt> (Python2 inside <tt class="docutils literal"><span class="pre">:-/</span></tt>)</li>
<li>Constant folding (it needs to make sure it manipulates pure functions)</li>
<li>…</li>
</ol>
</blockquote>
<p>But the single more important use of identifier binding is in fact, typing. This
is likely to evolve, but current (clumsy) typing system in Pythran attaches
some kind of typing properties to functions. For instance for the following
function:</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">):</span> <span class="n">x</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
</pre></div>
<p>Pythran computes a property that states</p>
<blockquote>
> if functions <tt class="docutils literal">foo</tt> is called with an argument of type A as first argument and an argument of type B as second argument,
> <strong>then</strong> the type of the first argument is the combination of its actual type A and an abstract type <em>Container of B</em></blockquote>
<p>So in case we make the following call:</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">b</span> <span class="o">=</span> <span class="p">[]</span>
<span class="gp">>>> </span><span class="n">foo</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
</pre></div>
<p>then the type of <tt class="docutils literal">a</tt> is first computed to be <em>empty list</em> and calling <tt class="docutils literal">foo</tt>
combines this information with the fact that <tt class="docutils literal">a</tt> must be capable of holding
integers, to conclude <tt class="docutils literal">a</tt> has the type <em>list of integers</em>.</p>
<p>Identifier binding is used twice in the process. Once to prove that the
<em>identifier</em> <tt class="docutils literal">foo</tt> is bound to the value <tt class="docutils literal">foo</tt>, and once to track which
values the <em>identifier</em> <tt class="docutils literal">a</tt> was bound to; here to compute that the type
information gathered for <tt class="docutils literal">a</tt> also impacts <tt class="docutils literal">b</tt>, even if <tt class="docutils literal">b</tt> was not used
in the function call, as they share the same value.</p>
</div>
<div class="section" id="computing-an-overset-of-the-bound-values">
<h2>Computing an Overset of the Bound Values</h2>
<p>Pythran <strong>cannot</strong> track any possible values bound to a variable. In the following example:</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1000</span><span class="p">):</span>
<span class="gp">... </span> <span class="k">pass</span>
</pre></div>
<p>identifier <tt class="docutils literal">i</tt> can be bound to a great deal of values, and we cannot track them individually.
Instead Pythran only keep tracks of values that are bound to an identifier. All
the others are hidden between the terms of <tt class="docutils literal"><span class="pre"><unbound-value></span></tt>.</p>
<p>So let's start to write some simple equations <a class="footnote-reference" href="#id5" id="id3">[1]</a>, with a few test cases demonstrated as Python code which needs some initialization:</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">ast</span>
<span class="gp">>>> </span><span class="kn">from</span> <span class="nn">pythran.analyses.aliases</span> <span class="kn">import</span> <span class="o">*</span>
<span class="gp">>>> </span><span class="kn">from</span> <span class="nn">pythran</span> <span class="kn">import</span> <span class="n">passmanager</span>
<span class="gp">>>> </span><span class="n">pm</span> <span class="o">=</span> <span class="n">passmanager</span><span class="o">.</span><span class="n">PassManager</span><span class="p">(</span><span class="s1">'demo'</span><span class="p">)</span>
</pre></div>
<p>Here, we basically inject the <tt class="docutils literal">aliases</tt> namespace into current namespace for
convenience, then create an instance of the object in charge of applying passes
and gathering analysis results.</p>
<div class="section" id="bool-op-expression">
<h3>Bool Op Expression</h3>
<p><em>(A.k.a ``or`` and ``and``)</em></p>
<p>Resulting node may alias to either operands:</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">'def foo(a, b): return a or b'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">BoolOp</span><span class="p">)</span>
<span class="go">(a or b) => ['a', 'b']</span>
</pre></div>
<p>This code snippet requires a few explanations:</p>
<blockquote>
<ol class="arabic simple">
<li>First, it parses a code snippet and turns it into an Abstract Syntax Tree (AST).</li>
<li><dl class="first docutils">
<dt>Second, it computes the alias information at every point of the program.</dt>
<dd><tt class="docutils literal">result</tt> is a dictionary that maps nodes from the AST to set of
identifiers (remember that for Pythran, a node can only alias to
bounded values. These values are represented by the first identifier
they are bound to).</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>Finally, it pretty prints the result of the analysis, using a filter to</dt>
<dd>only dump the part we are interested in. In that case it dumps a
textual representation of the alias set of the <tt class="docutils literal">ast.BoolOp</tt> nodes,
which turns out to be <tt class="docutils literal">['a', 'b']</tt>.</dd>
</dl>
</li>
</ol>
</blockquote>
</div>
<div class="section" id="unary-operator-expression">
<h3>Unary Operator Expression</h3>
<p>Resulting node does not alias to anything</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">'def foo(a): return -a'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">UnaryOp</span><span class="p">)</span>
<span class="go">(- a) => ['<unbound-value>']</span>
</pre></div>
<p>As stated previously, values not bound to an identifier are only represented as <tt class="docutils literal"><span class="pre"><unbound-value></span></tt>.</p>
</div>
<div class="section" id="if-expression">
<h3>If Expression</h3>
<p>Resulting node alias to either branch</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">'def foo(a, b, c): return a if c else b'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">IfExp</span><span class="p">)</span>
<span class="go">(a if c else b) => ['a', 'b']</span>
</pre></div>
</div>
<div class="section" id="dict-expression">
<h3>Dict Expression</h3>
<p>A dict is abstracted as an unordered container of its values</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">'def foo(a, b): return {0: a, 1: b}'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">Dict</span><span class="p">)</span>
<span class="go">{0: a, 1: b} => ['|a|', '|b|']</span>
</pre></div>
<p>where the <tt class="docutils literal">|id|</tt> notation means something that may contain <tt class="docutils literal">id</tt>.</p>
</div>
<div class="section" id="set-expression">
<h3>Set Expression</h3>
<p>A set is abstracted as an unordered container of its elements</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">'def foo(a, b): return {a, b}'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span>
<span class="go">{a, b} => ['|a|', '|b|']</span>
</pre></div>
</div>
<div class="section" id="tuple-expression">
<h3>Tuple Expression</h3>
<p>A tuple is abstracted as an ordered container of its values</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">'def foo(a, b): return a, b'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">Tuple</span><span class="p">)</span>
<span class="go">(a, b) => ['|[0]=a|', '|[1]=b|']</span>
</pre></div>
<p>where the <tt class="docutils literal"><span class="pre">|[i]=id|</span></tt> notation means something that
may contain <tt class="docutils literal">id</tt> at index <tt class="docutils literal">i</tt>.</p>
</div>
<div class="section" id="call-expression">
<h3>Call Expression</h3>
<p>Resulting node alias to the return_alias of called function,
if the function is already known by Pythran (i.e. it's an Intrinsic)
or if Pythran already computed it's <tt class="docutils literal">return_alias</tt> behavior.</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">fun</span> <span class="o">=</span> <span class="s1">'''</span>
<span class="gp">... </span><span class="s1">def f(a): return a</span>
<span class="gp">... </span><span class="s1">def foo(b): c = f(b)'''</span>
<span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">fun</span><span class="p">)</span>
</pre></div>
<p>The <tt class="docutils literal">f</tt> function create aliasing between
the returned value and its first argument.</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">Call</span><span class="p">)</span>
<span class="go">f(b) => ['b']</span>
</pre></div>
<p>This also works with intrinsics, e.g. <tt class="docutils literal">dict.setdefault</tt> which
may create alias between its third argument and the return value.</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">fun</span> <span class="o">=</span> <span class="s1">'def foo(a, d): __builtin__.dict.setdefault(d, 0, a)'</span>
<span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">fun</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">Call</span><span class="p">)</span>
<span class="go">__builtin__.dict.setdefault(d, 0, a) => ['<unbound-value>', 'a']</span>
</pre></div>
<p>Note that complex cases can arise, when one of the formal parameter
is already known to alias to various values:</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">fun</span> <span class="o">=</span> <span class="s1">'''</span>
<span class="gp">... </span><span class="s1">def f(a, b): return a and b</span>
<span class="gp">... </span><span class="s1">def foo(A, B, C, D): return f(A or B, C or D)'''</span>
<span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">fun</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">Call</span><span class="p">)</span>
<span class="go">f((A or B), (C or D)) => ['A', 'B', 'C', 'D']</span>
</pre></div>
</div>
<div class="section" id="subscript-expression">
<h3>Subscript Expression</h3>
<p>The resulting node alias only stores the subscript relationship if we don't know
anything about the subscripted node.</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">'def foo(a): return a[0]'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">Subscript</span><span class="p">)</span>
<span class="go">a[0] => ['a[0]']</span>
</pre></div>
<p>If we know something about the container, e.g. in case of a list, we
can use this information to get more accurate informations:</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">'def foo(a, b, c): return [a, b][c]'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">Subscript</span><span class="p">)</span>
<span class="go">[a, b][c] => ['a', 'b']</span>
</pre></div>
<p>Moreover, in case of a tuple indexed by a constant value, we can
further refine the aliasing information:</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">fun</span> <span class="o">=</span> <span class="s1">'''</span>
<span class="gp">... </span><span class="s1">def f(a, b): return a, b</span>
<span class="gp">... </span><span class="s1">def foo(a, b): return f(a, b)[0]'''</span>
<span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">fun</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">Subscript</span><span class="p">)</span>
<span class="go">f(a, b)[0] => ['a']</span>
</pre></div>
<p>Nothing is done for slices, even if the indices are known :-/</p>
<blockquote>
<pre class="doctest-block">
>>> module = ast.parse('def foo(a, b, c): return [a, b, c][1:]')
>>> result = pm.gather(Aliases, module)
>>> Aliases.dump(result, filter=ast.Subscript)
[a, b, c][1:] => ['<unbound-value>']
</pre>
</blockquote>
</div>
<div class="section" id="list-comprehension">
<h3>List Comprehension</h3>
<p>A comprehension is not abstracted in any way</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">'def foo(a, b): return [a for i in b]'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">ListComp</span><span class="p">)</span>
<span class="go">[a for i in b] => ['<unbound-value>']</span>
</pre></div>
</div>
<div class="section" id="return-statement">
<h3>Return Statement</h3>
<p>A side effect of computing aliases on a Return is that it updates the
<tt class="docutils literal">return_alias</tt> field of current function</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">'def foo(a, b): return a'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">module</span><span class="o">.</span><span class="n">body</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">return_alias</span> <span class="c1"># doctest: +ELLIPSIS</span>
<span class="go"><function merge_return_aliases at...></span>
</pre></div>
<p>This field is a function that takes as many nodes as the function
argument count as input and returns an expression based on
these arguments if the function happens to create aliasing
between its input and output. In our case:</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">f</span> <span class="o">=</span> <span class="n">module</span><span class="o">.</span><span class="n">body</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">return_alias</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">f</span><span class="p">([</span><span class="n">ast</span><span class="o">.</span><span class="n">Name</span><span class="p">(</span><span class="s1">'A'</span><span class="p">,</span> <span class="n">ast</span><span class="o">.</span><span class="n">Load</span><span class="p">()),</span> <span class="n">ast</span><span class="o">.</span><span class="n">Num</span><span class="p">(</span><span class="mi">1</span><span class="p">)]))</span>
<span class="go">['A']</span>
</pre></div>
<p>This also works if the relationship between input and output
is more complex:</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">'def foo(a, b): return a or b[0]'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">f</span> <span class="o">=</span> <span class="n">module</span><span class="o">.</span><span class="n">body</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">return_alias</span>
<span class="gp">>>> </span><span class="n">List</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">List</span><span class="p">([</span><span class="n">ast</span><span class="o">.</span><span class="n">Name</span><span class="p">(</span><span class="s1">'L0'</span><span class="p">,</span> <span class="n">ast</span><span class="o">.</span><span class="n">Load</span><span class="p">())],</span> <span class="n">ast</span><span class="o">.</span><span class="n">Load</span><span class="p">())</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">f</span><span class="p">([</span><span class="n">ast</span><span class="o">.</span><span class="n">Name</span><span class="p">(</span><span class="s1">'B'</span><span class="p">,</span> <span class="n">ast</span><span class="o">.</span><span class="n">Load</span><span class="p">()),</span> <span class="n">List</span><span class="p">]))</span>
<span class="go">['B', '[L0][0]']</span>
</pre></div>
<p>Which actually means that when called with two arguments <tt class="docutils literal">B</tt> and
the single-element list <tt class="docutils literal">[L[0]]</tt>, <tt class="docutils literal">foo</tt> may returns either the
first argument, or the first element of the second argument.</p>
</div>
<div class="section" id="assign-statement">
<h3>Assign Statement</h3>
<p>Assignment creates aliasing between lhs and rhs</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">'def foo(a): c = a ; d = e = c ; {c, d, e}'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span>
<span class="go">{c, d, e} => ['|a|', '|a|', '|a|']</span>
</pre></div>
<p>Everyone points to the formal parameter <tt class="docutils literal">a</tt> o/</p>
</div>
<div class="section" id="for-statement">
<h3>For Statement</h3>
<p>For loop creates aliasing between the target
and the content of the iterator</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">'''</span>
<span class="gp">... </span><span class="s1">def foo(a):</span>
<span class="gp">... </span><span class="s1"> for i in a:</span>
<span class="gp">... </span><span class="s1"> {i}'''</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span>
<span class="go">{i} => ['|i|']</span>
</pre></div>
<p>Not very useful, unless we know something about the iterated container</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">'''</span>
<span class="gp">... </span><span class="s1">def foo(a, b):</span>
<span class="gp">... </span><span class="s1"> for i in [a, b]:</span>
<span class="gp">... </span><span class="s1"> {i}'''</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span>
<span class="go">{i} => ['|a|', '|b|']</span>
</pre></div>
</div>
<div class="section" id="if-statement">
<h3>If Statement</h3>
<p>After an if statement, the values from both branches are merged,
potentially creating more aliasing:</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">fun</span> <span class="o">=</span> <span class="s1">'''</span>
<span class="gp">... </span><span class="s1">def foo(a, b):</span>
<span class="gp">... </span><span class="s1"> if a: c=a</span>
<span class="gp">... </span><span class="s1"> else: c=b</span>
<span class="gp">... </span><span class="s1"> return {c}'''</span>
<span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">fun</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">Aliases</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">Aliases</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="nb">filter</span><span class="o">=</span><span class="n">ast</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span>
<span class="go">{c} => ['|a|', '|b|']</span>
</pre></div>
</div>
<div class="section" id="illustration-typing">
<h3>Illustration: Typing</h3>
<p>Thanks to the above analysis, Pythran is capable of computing some rather difficult informations! In the following:</p>
<div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">typing_aliasing_and_variable_subscript_combiner</span><span class="p">(</span><span class="n">i</span><span class="p">):</span>
<span class="n">a</span><span class="o">=</span><span class="p">[</span><span class="nb">list</span><span class="o">.</span><span class="n">append</span><span class="p">,</span>
<span class="k">lambda</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">:</span> <span class="n">x</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="n">y</span><span class="p">])</span>
<span class="p">]</span>
<span class="n">b</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">a</span><span class="p">[</span><span class="n">i</span><span class="p">](</span><span class="n">b</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
<span class="k">return</span> <span class="n">b</span>
</pre></div>
<p>Pythran knows that <tt class="docutils literal">b</tt> is a list of elements of the same type as <tt class="docutils literal">i</tt>.</p>
<p>And in the following:</p>
<div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">typing_and_function_dict</span><span class="p">(</span><span class="n">a</span><span class="p">):</span>
<span class="n">funcs</span> <span class="o">=</span> <span class="p">{</span>
<span class="s1">'zero'</span> <span class="p">:</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span>
<span class="s1">'one'</span> <span class="p">:</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span>
<span class="p">}</span>
<span class="n">s</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span>
<span class="n">funcs</span><span class="p">[</span><span class="n">a</span><span class="p">](</span><span class="n">s</span><span class="p">)</span>
<span class="k">return</span> <span class="n">s</span>
</pre></div>
<p>Pythran knows that <tt class="docutils literal">s</tt> is a set of integers :-)</p>
</div>
<div class="section" id="illustration-dead-code-elimination">
<h3>Illustration: Dead Code Elimination</h3>
<p>Consider the following sequence:</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">fun</span> <span class="o">=</span> <span class="s1">'''</span>
<span class="gp">... </span><span class="s1">def useless0(x): return x + 1</span>
<span class="gp">... </span><span class="s1">def useless1(x): return x - 1</span>
<span class="gp">... </span><span class="s1">def useful(i):</span>
<span class="gp">... </span><span class="s1"> funcs = useless0, useless1</span>
<span class="gp">... </span><span class="s1"> funcs[i%2](i)</span>
<span class="gp">... </span><span class="s1"> return i'''</span>
</pre></div>
<p>Pythran can prove that both <tt class="docutils literal">useless0</tt> and <tt class="docutils literal">useless1</tt> don't have side
effects. Thanks to the binded value analysis, it can also prove that
<strong>whatever</strong> the index, <tt class="docutils literal">funcs[something]</tt> either points to <tt class="docutils literal">useless0</tt> or
<tt class="docutils literal">useless1</tt>. And in either cases, the function has no side effect, which means
we can remove the whole instruction:</p>
<div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">pythran.optimizations</span> <span class="kn">import</span> <span class="n">DeadCodeElimination</span>
<span class="gp">>>> </span><span class="kn">from</span> <span class="nn">pythran.backend</span> <span class="kn">import</span> <span class="n">Python</span>
<span class="gp">>>> </span><span class="n">module</span> <span class="o">=</span> <span class="n">ast</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">fun</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">_</span><span class="p">,</span> <span class="n">module</span> <span class="o">=</span> <span class="n">pm</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="n">DeadCodeElimination</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="gp">>>> </span><span class="k">print</span> <span class="n">pm</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">Python</span><span class="p">,</span> <span class="n">module</span><span class="p">)</span>
<span class="go">def useless0(x):</span>
<span class="go"> return (x + 1)</span>
<span class="go">def useless1(x):</span>
<span class="go"> return (x - 1)</span>
<span class="go">def useful(i):</span>
<span class="go"> funcs = (useless0, useless1)</span>
<span class="go"> pass</span>
<span class="go"> return i</span>
</pre></div>
<p>Other optimizations will take care of removing the useless assignment to <tt class="docutils literal">funcs</tt> :-)</p>
</div>
</div>
<div class="section" id="acknowledgments">
<h2>Acknowledgments</h2>
<p>Thanks a lot to Pierrick Brunet for his careful review, and to Florent Cayré from <a class="reference external" href="https://www.logilab.fr/">Logilab</a> for his advices that helped <strong>a lot</strong> to improve the post. And of course to <a class="reference external" href="http://opendreamkit.org/">OpenDreamKit</a> for funding this work!</p>
<table class="docutils footnote" frame="void" id="id4" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id2">[0]</a></td><td>Except the sanity of the developer, but who never used the <tt class="docutils literal">id</tt> or <tt class="docutils literal">len</tt> identifiers?</td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="id5" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id3">[1]</a></td><td>Starting from this note, the identifiers from the <a class="reference external" href="https://docs.python.org/2/library/ast.html">ast</a> module are used.</td></tr>
</tbody>
</table>
<table class="docutils citation" frame="void" id="git-version" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id1">[git-version]</a></td><td>The Pythran commit id used for this article is <tt class="docutils literal">f38a16491ea644fbaed15e8facbcabf869637b39</tt></td></tr>
</tbody>
</table>
</div>
</div><!-- /.entry-content -->
</article>
</section>
</div><!--/span-->
<div class="span3 well sidebar-nav" id="sidebar">
<ul class="nav nav-list">
<li class="nav-header"><h4><i class="icon-external-link"></i>blogroll</h4></li>
<li><a href="http://pythonhosted.org/pythran"><i class="icon-external-link"></i>Pythran Doc</a></li>
<li><a href="https://pypi.python.org/pypi/pythran"><i class="icon-external-link"></i>Pythran on PyPI</a></li>
<li class="nav-header"><h4><i class="icon-home icon-large"></i> social</h4></li>
<li><a href="./feeds/all.atom.xml" rel="alternate"><i class="icon-bookmark icon-large"></i>atom feed</a></li>
<li><a href="https://github.com/serge-sans-paille/pythran"><i class="icon-github-sign icon-large"></i>github</a></li>
<li class="nav-header"><h4><i class="icon-folder-close icon-large"></i>Categories</h4></li>
<li>
<a href="./category/benchmark.html">
<i class="icon-folder-open icon-large"></i>benchmark
</a>
</li>
<li>
<a href="./category/compilation.html">
<i class="icon-folder-open icon-large"></i>compilation
</a>
</li>
<li>
<a href="./category/cython.html">
<i class="icon-folder-open icon-large"></i>cython
</a>
</li>
<li>
<a href="./category/engineering.html">
<i class="icon-folder-open icon-large"></i>engineering
</a>
</li>
<li>
<a href="./category/examples.html">
<i class="icon-folder-open icon-large"></i>examples
</a>
</li>
<li>
<a href="./category/optimisation.html">
<i class="icon-folder-open icon-large"></i>optimisation
</a>
</li>
<li>
<a href="./category/release.html">
<i class="icon-folder-open icon-large"></i>release
</a>
</li>
<li class="nav-header"><h4><i class="icon-tags icon-large"></i>Tags</h4></li>
</ul> </div><!--/.well -->
</div><!--/row-->
<hr>
<footer>
<address id="about">
Proudly powered by <a href="http://pelican.notmyidea.org/">Pelican <i class="icon-external-link"></i></a>,
which takes great advantage of <a href="http://python.org">Python <i class="icon-external-link"></i></a>.
</address><!-- /#about -->
<p>The theme is from <a href="http://twitter.github.com/bootstrap/">Bootstrap from Twitter <i class="icon-external-link"></i></a>,
and <a href="http://fortawesome.github.com/Font-Awesome/">Font-Awesome <i class="icon-external-link"></i></a>, thanks!</p>
</footer>
</div><!--/.fluid-container-->
<!-- Le javascript -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./theme/js/jquery-1.7.2.min.js"></script>
<script src="./theme/js/bootstrap.min.js"></script>
</body>
</html>