Commit 6fec02f2 authored by Pallav Agarwal's avatar Pallav Agarwal

New Tip added. Cython.

parent 5e8c228a
......@@ -159,6 +159,10 @@ But what makes IITK special is that even first years are part of the team. In ro
<h4>RECENT TIPS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/27/Boost-Python-Performance/" class="color_change">Cython: Boost Python Code Performance</a>
</li>
<li>
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class="color_change">Wrath of Linux Package Managers</a>
</li>
......
......@@ -164,6 +164,10 @@ be as perfect as other linux package managers.</p>
<h4>RECENT TIPS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/27/Boost-Python-Performance/" class="color_change">Cython: Boost Python Code Performance</a>
</li>
<li>
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class="color_change">Wrath of Linux Package Managers</a>
</li>
......
......@@ -115,6 +115,10 @@ I found that using:</p>
<h4>RECENT TIPS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/27/Boost-Python-Performance/" class="color_change">Cython: Boost Python Code Performance</a>
</li>
<li>
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class="color_change">Wrath of Linux Package Managers</a>
</li>
......
......@@ -184,6 +184,10 @@ it is time to customize your own.</p>
<h4>RECENT TIPS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/27/Boost-Python-Performance/" class="color_change">Cython: Boost Python Code Performance</a>
</li>
<li>
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class="color_change">Wrath of Linux Package Managers</a>
</li>
......
......@@ -148,6 +148,10 @@ or using the <code>:help key-notation</code> command inside vim.</p>
<h4>RECENT TIPS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/27/Boost-Python-Performance/" class="color_change">Cython: Boost Python Code Performance</a>
</li>
<li>
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class="color_change">Wrath of Linux Package Managers</a>
</li>
......
......@@ -232,6 +232,10 @@ endif
<h4>RECENT TIPS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/27/Boost-Python-Performance/" class="color_change">Cython: Boost Python Code Performance</a>
</li>
<li>
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class="color_change">Wrath of Linux Package Managers</a>
</li>
......
......@@ -199,6 +199,10 @@ case sensitive for example, the correct names for the above are:</p>
<h4>RECENT TIPS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/27/Boost-Python-Performance/" class="color_change">Cython: Boost Python Code Performance</a>
</li>
<li>
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class="color_change">Wrath of Linux Package Managers</a>
</li>
......
......@@ -159,6 +159,10 @@ to start with.</p>
<h4>RECENT TIPS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/27/Boost-Python-Performance/" class="color_change">Cython: Boost Python Code Performance</a>
</li>
<li>
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class="color_change">Wrath of Linux Package Managers</a>
</li>
......
......@@ -156,6 +156,10 @@ will step on each other's files and overwrite each other's essential files.</p>
<h4>RECENT TIPS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/27/Boost-Python-Performance/" class="color_change">Cython: Boost Python Code Performance</a>
</li>
<li>
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class="color_change">Wrath of Linux Package Managers</a>
</li>
......
<title>Cython: Boost Python Code Performance - VARSTACK</title>
<meta name=viewport content="width=device-width, initial-scale=1">
<meta charset="utf-8"/>
<noscript>
<link href="/css/bootstrap.min.css" rel="stylesheet">
<link href="/css/highlighting.css" rel="stylesheet">
<link href="/css/style.css" rel="stylesheet">
</noscript>
<script id="loadcss">function loadCSS(e,n,o,t){"use strict";var d=window.document.createElement("link"),i=n||window.document.getElementsByTagName("script")[0],r=window.document.styleSheets;return d.rel="stylesheet",d.href=e,d.media="only x",t&&(d.onload=t),i.parentNode.insertBefore(d,i),d.onloadcssdefined=function(e){for(var n,o=0;o<r.length;o++)r[o].href&&r[o].href===d.href&&(n=!0);n?e():setTimeout(function(){d.onloadcssdefined(e)})},d.onloadcssdefined(function(){d.media=o||"all"}),d}
loadCSS( "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css", document.getElementById("loadcss"));
loadCSS( "/css/highlighting.css", document.getElementById("loadcss"));
loadCSS( "/css/style.css", document.getElementById("loadcss"));
</script>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<div class="container">
<div class="row" id="menu">
<div class="col-md-3 col-xs-8 menu" id="site_title">
<a href="/" style="color:black;">VARSTACK</a>
</div>
<div class="col-md-3 col-md-push-6 col-xs-4 menu">
<form action="/search/" id='search-form'>
<input id="search-box" type="text" name="query" placeholder="Search..">
</form>
</div>
<div class="col-md-6 col-md-pull-3 col-xs-12 menu">
<div class="row" id="top_menu">
<ul class="nav nav-pills">
<li class="active" id="blog"><a class="color_change" href="/">Blog</a></li>
<li id="tips"><a class="color_change" href="/tips/">Tips</a></li>
<li id="algo"><a class="color_change" href="/algo/">Behind The Scenes</a></li>
<li id="about"><a class="color_change" href="/about_me/">About Me</a></li>
</ul>
</div>
</div>
</div>
<div class="row" id="content">
<div class="col-md-7 col-md-push-3">
<div class="row" id="data">
<div class="col-md-12">
<br />
<h3>Cython: Boost Python Code Performance</h3>
<hr />
<div class="row text-justify" id="content-holder">
<div class="col-md-12">
<p>This tip is for those people who have been working on large python projects and the fact
that python is a slow language as compared to statically compiled languages has finally
caught up with them. This tip is about Cython, what it is and where can you use
it for maximum effect.</p>
<p><br /></p>
<h4><strong>What is Cython?</strong></h4>
<p>From the docs themselves,</p>
<blockquote><p>Cython is an optimising static compiler for both the Python programming language and
the extended Cython programming language (based on Pyrex).</p>
<p>The Cython language is a superset of the Python language that additionally supports
calling C functions and declaring C types on variables and class attributes. This
allows the compiler to generate very efficient C code from Cython code. The C
code is generated once and then compiles with all major C/C++ compilers in CPython
2.6, 2.7 (2.4+ with Cython 0.20.x) as well as 3.2 and all later versions.</p></blockquote>
<p><br /></p>
<h4><strong>How do I use it?</strong></h4>
<p>The documentation is pretty complete in itself. However to give you a general idea,
let's say you have to process two strings in python. First part of the processing requires
you to, lets say, find the
<a href="https://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein distance</a> of the two
strings (Real World example from a project of mine). In python, even the most efficient
implementation of the algorithm was taking over two seconds for two significantly long
strings.</p>
<p><a href="/img/code-diff.png">Here</a> is the code and the changes I had to make for the speedup.</p>
<h4><strong>The result??</strong></h4>
<p>Just with 4 lines of changes, I got over 15x speedup! What actually happens is that by
adding static type declarations to the most used variables in the time hogging fnx,
you are telling Cython to treat them as those types, and assign C semantics to those,
translating it to very efficient C code.</p>
<p>I'll now leave you alone, while you explore Cython's extensive documentation, and pride
yourself on reading this post.</p>
<p>I hope that helped. Please Share. :)</p>
</div>
</div>
</div>
</div>
<hr /><br />
</div>
<div class="col-md-3 col-md-pull-7" id="recent">
<h4>RECENT POSTS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/09/Vim-Plugins/" class="color_change">Essential VIM plugins</a>
</li>
<li>
<a href="/2015/07/08/Vim-Colorscheme/" class="color_change">VIM: Setting a colorscheme</a>
</li>
<li>
<a href="/2015/07/03/Vim-Plug-Plugin-Manager/" class="color_change">Plugin Management in VIM</a>
</li>
<li>
<a href="/2015/07/01/Vim-Customization/" class="color_change">Vim Customization: Guide to writing your...</a>
</li>
<li>
<a href="/2015/06/26/Linuxbrew/" class="color_change">Package Management without root access -...</a>
</li>
</ul>
<h4>RECENT TIPS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/27/Boost-Python-Performance/" class="color_change">Cython: Boost Python Code Performance</a>
</li>
<li>
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class="color_change">Wrath of Linux Package Managers</a>
</li>
<li>
<a href="/2015/07/01/Vim-Mappings/" class="color_change">Quick intro to custom Vim Mappings...</a>
</li>
<li>
<a href="/2015/06/30/Mouse-with-vim/" class="color_change">Using Mouse with VIM in the...</a>
</li>
</ul>
<br />
<br />
</div>
<div class="col-md-2">
</div>
<div class="row">
<div class="col-md-7 col-md-offset-3 col-xs-10 col-xs-offset-1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="/js/SmoothScroll.js"></script>
<script src="/js/script.js"></script>
<script src="/js/tips.js"></script>
<script type="text/javascript">var switchTo5x=true;</script>
<script type="text/javascript">stLight.options({publisher: "7839e2af-f9d1-4f68-9304-dcf13d3352ea", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script>
<span class='st_sharethis_large' displayText='ShareThis'></span>
<span class='st_facebook_large' displayText='Facebook'></span>
<span class='st_twitter_large' displayText='Tweet'></span>
<span class='st_googleplus_large' displayText='Google +'></span>
<span class='st_linkedin_large' displayText='LinkedIn'></span>
<span class='st_pinterest_large' displayText='Pinterest'></span>
<div id="disqus_thread"></div>
<script type="text/javascript" async>
/* * * CONFIGURATION VARIABLES * * */
var disqus_shortname = 'varstack';
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-21768487-2', 'auto');
ga('send', 'pageview');
</script>
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js" async></script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
</div>
</div>
</div>
</div>
<div class="modal fade" id="imagemodal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">
Image Preview
</h4>
</div>
<div class="modal-body">
<img src="" id="imagepreview" style="max-height: 100%; max-width: 100%;">
</div>
</div>
</div>
</div>
......@@ -133,6 +133,10 @@ I had trouble finding the answers to.</p>
<h4>RECENT TIPS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/27/Boost-Python-Performance/" class="color_change">Cython: Boost Python Code Performance</a>
</li>
<li>
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class="color_change">Wrath of Linux Package Managers</a>
</li>
......
......@@ -188,6 +188,10 @@ or website, you can do so (the source code for everything is public on
<h4>RECENT TIPS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/27/Boost-Python-Performance/" class="color_change">Cython: Boost Python Code Performance</a>
</li>
<li>
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class="color_change">Wrath of Linux Package Managers</a>
</li>
......
......@@ -57,6 +57,15 @@ loadCSS( "/css/style.css", document.getElementById("loadcss"));
<div class="row text-justify" id="content-holder">
<div class="col-md-12">
<a href="/2015/07/27/Boost-Python-Performance/">CYTHON: BOOST PYTHON CODE PERFORMANCE</a>
<p class="author" style="text-align: right;">
<span class="date">Jul 27, 2015</span>
</p>
<div class="content">
<p>This tip is for those people who have been working on large python projects and the fact that python is a slow language as compared to statically compiled languages has finally caught up with them. This tip is about Cython, what it is and where can you use it for maximum effect.</p> <p><br /></p> <h4><strong>What is Cython?</strong></h4> <p>From the docs themselves,</p> <blockquote><p>Cython is an optimising static compiler for both the Python programming language and the extended Cython programming language (based on Pyrex).</p> <p>The Cython language is a superset of the Python language that additionally supports calling C functions and declaring...
</div>
<br /><br />
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/">WRATH OF LINUX PACKAGE MANAGERS</a>
<p class="author" style="text-align: right;">
<span class="date">Jul 09, 2015</span>
......@@ -180,6 +189,10 @@ loadCSS( "/css/style.css", document.getElementById("loadcss"));
<h4>RECENT TIPS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/27/Boost-Python-Performance/" class="color_change">Cython: Boost Python Code Performance</a>
</li>
<li>
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class="color_change">Wrath of Linux Package Managers</a>
</li>
......
......@@ -57,6 +57,22 @@ loadCSS( "/css/search.css", document.getElementById("loadcss"));
<div class="row text-justify" id="content-holder">
<div class="col-md-12">
<div class="post">
<a href="/2015/07/27/Boost-Python-Performance/" class='shead'>
Cython: Boost Python Code Performance
</a>
<br />
<div class="excerpt">
This tip is for those people who have been working on large python projects and the fact that python is a slow language as compared.......I'll now leave you alone, while you explore Cython's extensive documentation, and pride yourself on reading this post. I hope that helped. Please Share. :)
</div>
<br />
<div class='tags'>
Cython:9, language:6, code:5, python:4, type:3, string:3, compiler:3, C code:3, type declarations:1, result:1, python projects:1, class attributes:1, Real World example:1, Python programming language:1, Python language:1, Levenshtein distance:1, First part:1, Cython programming language:1, Cython language:1, Cython code:1, Cython 0 20 x:1, CPython 2 6 2 7 2 4:1, C types:1, C semantics:1, C functions:1, C C compilers:1, 4 lines:1, 15 x speedup:1,
</div>
</div>
<div class="post">
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class='shead'>
Wrath of Linux Package Managers
......@@ -236,6 +252,10 @@ loadCSS( "/css/search.css", document.getElementById("loadcss"));
<h4>RECENT TIPS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/27/Boost-Python-Performance/" class="color_change">Cython: Boost Python Code Performance</a>
</li>
<li>
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class="color_change">Wrath of Linux Package Managers</a>
</li>
......
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.varstack.com/2015/07/27/Boost-Python-Performance/</loc>
<lastmod>2015-07-27T00:00:00+05:30</lastmod>
</url>
<url>
<loc>http://www.varstack.com/2015/07/09/Wrath-of-Linux-Package-Managers/</loc>
<lastmod>2015-07-09T00:00:00+05:30</lastmod>
......
......@@ -52,21 +52,30 @@ loadCSS( "/css/style.css", document.getElementById("loadcss"));
<hr />
<div class="row text-justify" id="content-holder">
<div class="col-md-12">
<p><strong><a href="/2015/07/09/Wrath-of-Linux-Package-Managers/">WRATH OF LINUX PACKAGE MANAGERS</a></strong></p>
<p><strong><a href="/2015/07/27/Boost-Python-Performance/">CYTHON: BOOST PYTHON CODE PERFORMANCE</a></strong></p>
<p>We all love to characterise things as <em>"More than the sum of it's parts"</em>. We'd like to say the same about our linux operating system. My <strong>ARCH</strong> is more than the sum of it's parts! Well.. no.</p>
<p>This tip is for those people who have been working on large python projects and the fact that python is a slow language as compared to statically compiled languages has finally caught up with them. This tip is about Cython, what it is and where can you use it for maximum effect.</p>
<p> <p>A linux system is exactly the sum of it's parts. And most of those parts are connected to the base package manager, the beast that acts like a framework, holding everything together.</p> <p>Have...</p>
<p> <p><br></p> <h4><strong>What is Cython?</strong></h4> <p>From the docs themselves,</p> <blockquote><p>Cython is an optimising static compiler for both the...</p></blockquote></p>
<p><br /></p>
<p><strong><a href="/2015/07/09/Wrath-of-Linux-Package-Managers/">WRATH OF LINUX PACKAGE MANAGERS</a></strong></p>
<p>We all love to characterise things as "More than the sum of it's parts". We'd like to say the same about our linux operating system. My <strong>ARCH</strong> is more than the sum of it's parts! Well.. no.</p>
<p> <p>A linux system is exactly the sum of it's parts. And most of those parts are connected to the base package manager, the beast that acts like a framework, holding everything together.</p> <p>Have...</p></p>
<p><br /></p>
<p><strong><a href="/2015/07/01/Vim-Mappings/">QUICK INTRO TO CUSTOM VIM MAPPINGS</a></strong></p>
<p>One of the best things about vim is its ability to create custom mappings for <em>almost</em> any key in all modes.</p>
<p>One of the best things about vim is its ability to create custom mappings for almost any key in all modes.</p>
<p> <p>Suppose you want Ctrl+S to save your document while you are in insert mode, because pressing</p> <pre><code>&lt;Esc&gt;:w&lt;Enter&gt;i </code></pre> <p>to switch to normal mode, save the file, and return back to insert mode is a bit too much. According to vim philosophy, it actually <strong>is</strong> too much, and thus you...</p>
<p> <p>Suppose you want Ctrl+S to save your document while you are in insert mode, because pressing</p> &lt;Esc&gt;:w&lt;Enter&gt;i <p>to switch to normal mode, save the file, and return back to insert mode is a bit too much. According to vim philosophy, it actually <strong>is</strong> too much, and thus you...</p></p>
<p><br /></p>
......@@ -75,7 +84,7 @@ loadCSS( "/css/style.css", document.getElementById("loadcss"));
<p>Just when you thought vim couldn't surprise you anymore, vim strikes again. As it turns out, vim supports mouse integration even in the terminal. Not only that, the support is mind blowingly simple and amazing. You can move your cursor, select text and even resize your panes in a split screen.</p>
<p> <p>Most websites just say to use <code>set mouse=a</code> in your <code>.vimrc</code> to add mouse support to your vim. However,...</p>
<p> <p>Most websites just say to use set mouse=a in your .vimrc to add mouse support to your vim. However,...</p></p>
<p><br /></p>
......@@ -113,6 +122,10 @@ loadCSS( "/css/style.css", document.getElementById("loadcss"));
<h4>RECENT TIPS</h4>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="/2015/07/27/Boost-Python-Performance/" class="color_change">Cython: Boost Python Code Performance</a>
</li>
<li>
<a href="/2015/07/09/Wrath-of-Linux-Package-Managers/" class="color_change">Wrath of Linux Package Managers</a>
</li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment