<?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>O Blog do Gustavo Felisberto &#187; python</title>
	<atom:link href="http://blog.felisberto.net/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.felisberto.net</link>
	<description>Life, the universe and all the rest</description>
	<lastBuildDate>Tue, 15 Mar 2011 11:57:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>from heapq import *</title>
		<link>http://blog.felisberto.net/2007/04/30/from-heapq-import/</link>
		<comments>http://blog.felisberto.net/2007/04/30/from-heapq-import/#comments</comments>
		<pubDate>Mon, 30 Apr 2007 12:34:21 +0000</pubDate>
		<dc:creator>Gustavo Felisberto</dc:creator>
				<category><![CDATA[Ciência/Tecnologia]]></category>
		<category><![CDATA[Geral]]></category>
		<category><![CDATA[heap]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.felisberto.net/2007/04/30/from-heapq-import/</guid>
		<description><![CDATA[Fantástico&#8230; Já gosto outra vez de python Em vez de ter de implementar uma heap como me aconteceu em Java, o meu querido python já tem uma implementada por mim. Mas o que é uma heap? Simplificando uma heap é uma estrutura em árvore que tem a particularidade de ter na raiz o nó com [...]]]></description>
			<content:encoded><![CDATA[<p><span class="dropcap">F</span>antástico&#8230; Já gosto outra vez de python <img src='http://blog.felisberto.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Em vez de ter de implementar uma heap como me aconteceu em Java, o meu querido python já tem uma implementada por mim.</p>
<blockquote><p><em>Mas o que é uma heap?</em></p></blockquote>
<p>Simplificando uma heap é uma estrutura em árvore que tem a particularidade de ter na raiz o nó com menor ou maio valor que existe na árvore. Em adição tem custos baixos, O( ln( n ) ) , para grande parte das operações básicas, tais como adição e remoção de nós.</p>
<blockquote><p><em>Mas a implementação em python é uma min-heap e eu preciso de uma max</em></p></blockquote>
<p>Duhhhhh&#8230;.. em vez de:<br />
[code lang="python"]def __cmp__(self, other):<br />
        return cmp(self.getHeuristica(), other.getHeuristica())[/code]</p>
<p>Basta usar:<br />
[code lang="python"]def __cmp__(self, other):<br />
        return other.getHeuristica() - self.getHeuristica() [/code]</p>
<p>Não li atentamente o código da heap que vem com o python, mas fiquei com a ideia que seria a clássica Heap Binária. No meu caso onde facilmente tenho algumas dezenas de milhares de nós e estou constantemente a tirar um e meter uns 20, talvez fosse interessante uma fibonacci heap&#8230;&#8230;. Fica para outro dia.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.felisberto.net/2007/04/30/from-heapq-import/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python Threads and the GIL</title>
		<link>http://blog.felisberto.net/2007/04/11/python-threads-and-the-gil/</link>
		<comments>http://blog.felisberto.net/2007/04/11/python-threads-and-the-gil/#comments</comments>
		<pubDate>Wed, 11 Apr 2007 15:08:29 +0000</pubDate>
		<dc:creator>Gustavo Felisberto</dc:creator>
				<category><![CDATA[Ciência/Tecnologia]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[gil]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[threads]]></category>

		<guid isPermaLink="false">http://blog.felisberto.net/2007/04/11/python-threads-and-the-gil/</guid>
		<description><![CDATA[The Global Interpreter Lock is python&#8217;s way of solving the issues of multiple threads running on multiple cpu&#8217;s thrashing common data. What happens is that only one thread runs at any time. In the last week I&#8217;ve been implementing some search algorithms that would greatly benefit from multiple threads on multiple cpu&#8217;s. Some of you [...]]]></description>
			<content:encoded><![CDATA[<p><span class="dropcap">T</span>he Global Interpreter Lock is python&#8217;s way of solving the issues of multiple threads running on multiple cpu&#8217;s thrashing common data.<br />
What happens is that only one thread runs at any time.<br />
In the last week I&#8217;ve been implementing some search algorithms that would greatly benefit from multiple threads on multiple cpu&#8217;s. Some of you might say:</p>
<blockquote><p>If you are using Unix or Cygwin you can use os.fork()</p></blockquote>
<p>Yes I can, but I&#8217;m not even going to delve into the issues around Threads VS Fork in terms of the time it will take to spawn a thread or spawn another process. </p>
<p>In the work I was doing I would use threads to do very small (as in time) tasks, but spawning many threads in a small amount of time. Seems I&#8217;ll have to re-think the approach&#8230;..</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.felisberto.net/2007/04/11/python-threads-and-the-gil/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

