<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>rlazo&#039;s blog &#187; Python</title>
	<atom:link href="http://www.rlazo.org/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rlazo.org</link>
	<description></description>
	<lastBuildDate>Sat, 08 May 2010 18:24:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Create a tarball from a specific git commit</title>
		<link>http://www.rlazo.org/2010/03/13/create-a-tarball-from-a-specific-git-commit/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://www.rlazo.org/2010/03/13/create-a-tarball-from-a-specific-git-commit/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 03:10:28 +0000</pubDate>
		<dc:creator>Rodrigo</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.rlazo.org/?p=180</guid>
		<description><![CDATA[I have this code I&#8217;m working on that is needs to be deployed remotely (Fabric makes this SO easy) and I&#8217;m using git as my version control system. Well, I was creating tarballs for this, but I was basically doing them as similar as I could to what git had in the tree (ignoring the [...]]]></description>
			<content:encoded><![CDATA[<p>I have this code I&#8217;m working on that is needs to be deployed remotely (<a href="http://docs.fabfile.org/0.9.0/index.html">Fabric makes this SO easy</a>) and I&#8217;m using git as my version control system. Well, I was creating tarballs for this, but I was basically doing them as similar as I could to what git had in the tree (ignoring the same files, etc.), so it was kind of repetitive and, boring. Well, git to the rescue!!!</p>
<p><code><br />
git archive --format=tar HEAD | gzip > myproject.tar.gz<br />
</code></p>
<p>And you have a nice clean zipped tarball of your code as is on HEAD, without tears <img src='http://www.rlazo.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Git is awesome!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rlazo.org/2010/03/13/create-a-tarball-from-a-specific-git-commit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Performance of in operator using list and set</title>
		<link>http://www.rlazo.org/2010/02/25/performance-of-in-operator-using-list-and-set/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://www.rlazo.org/2010/02/25/performance-of-in-operator-using-list-and-set/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 04:16:49 +0000</pubDate>
		<dc:creator>Rodrigo</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.rlazo.org/?p=163</guid>
		<description><![CDATA[I had this use case where I have to check which elements of a list of words where available in another list of words. So I decided to use the operator in﻿. Just for further reference a tried the following:

# common code for all test
base_list = [...]
query_list = [...]


Pretty simple method:

for word in query_list:
  [...]]]></description>
			<content:encoded><![CDATA[<p>I had this use case where I have to check which elements of a list of words where available in another list of words. So I decided to use the operator <strong>in﻿.</strong> Just for further reference a tried the following:</p>
<div>
<pre name="code" class="python"># common code for all test
base_list = [...]
query_list = [...]</pre>
</div>
<ol>
<li><strong>Pretty simple method:</strong>
<div>
<pre name="code" class="python">for word in query_list:
  if word in base_list:
    # do something</pre>
</div>
<p>For a list of 4284 elements against a list of 107 it took 9 seconds. Using simple lists, this method is the most straight forward of all, and also the slowest one.</li>
<li><strong>Sorting things:</strong>
<div>
<pre name="code" class="python">base_list.sort()
for word in query_list:
  if word in base_list:
    # do something</pre>
</div>
<p>After sorting the list, guess what? Yeap, nothing changed, same 9 seconds</li>
<li><strong>What about sets?</strong>
<div>
<pre name="code" class="python">bs = set(base_list)
for word in query_list:
  if word in bs:
    # do something</pre>
</div>
<p>Using sets this is <strong>another history</strong>, 0.6 seconds for the same amount of data; but&#8230; if this could be achived turning one of lists into a set, what if&#8230;</li>
<li><strong>Using more sets</strong>
<div>
<pre name="code" class="python">bs = set(base_list)
qs = set(query_list)
solution = bs.intersection(qs)</pre>
</div>
<p>0.02 seconds.</li>
</ol>
<p>Well, as you can see, sets are great.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rlazo.org/2010/02/25/performance-of-in-operator-using-list-and-set/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
