<?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>bgola &#187; gsoc</title>
	<atom:link href="http://blog.brunogola.com.br/tag/gsoc/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.brunogola.com.br</link>
	<description>python, free software, hacking, free culture, bicycle commuting, geocaching</description>
	<lastBuildDate>Wed, 08 Dec 2010 12:49:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>PyPy 2.5-features &#8211; Starting to port the standard lib</title>
		<link>http://blog.brunogola.com.br/2008/08/pypy-25-features-starting-to-port-the-standard-lib/</link>
		<comments>http://blog.brunogola.com.br/2008/08/pypy-25-features-starting-to-port-the-standard-lib/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 17:23:02 +0000</pubDate>
		<dc:creator>Bruno Gola</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[pypy]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[2.5-features]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[pep]]></category>
		<category><![CDATA[pep328]]></category>
		<category><![CDATA[status report]]></category>
		<category><![CDATA[stdlib]]></category>

		<guid isPermaLink="false">http://blog.brunogola.com.br/?p=48</guid>
		<description><![CDATA[A little late I know. This week I finished to fix all the failing tests and to implement PEP 328 (Absolute/Relative import). Now it&#8217;s the final step for supporting Python2.5 on PyPy, to port the standard library. I&#8217;m starting with it today and I really hope I can finish it all (including tests and everything [...]]]></description>
			<content:encoded><![CDATA[<p>A little late I know.</p>
<p>This week I finished to fix all the failing tests and to implement PEP 328 (Absolute/Relative import).</p>
<p>Now it&#8217;s the final step for supporting Python2.5 on PyPy, to port the standard library.</p>
<p>I&#8217;m starting with it today and I really hope I can finish it all (including tests and everything else) until the end of next week. </p>
<p>Well, one more time, if anyone want to help me, test your python programs (specially the ones that use python2.5 specific features, like with statement, conditional expressions and new generator stuff) in PyPy-2.5-features (<code>svn co http://codespeak.net/svn/pypy/2.5-features pypy-2.5-features</code>). </p>
<p>How to test? Simple:</p>
<p><code><br />
$ cd pypy-2.5-features<br />
$ ./bin/py.py your_python_program.py<br />
</code></p>
<p>Be careful and patient, it may take a little bit to things start happening <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Of course you can translate PyPy using the translator if you want. Take a look at PyPy&#8217;s website for more information. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brunogola.com.br/2008/08/pypy-25-features-starting-to-port-the-standard-lib/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Code Jam &#8211; Round 1</title>
		<link>http://blog.brunogola.com.br/2008/07/google-code-jam-round-1/</link>
		<comments>http://blog.brunogola.com.br/2008/07/google-code-jam-round-1/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 14:53:40 +0000</pubDate>
		<dc:creator>Bruno Gola</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[gcj]]></category>
		<category><![CDATA[gsoc]]></category>

		<guid isPermaLink="false">http://blog.brunogola.com.br/?p=47</guid>
		<description><![CDATA[Just to update my blog, let&#8217;s get ready to GCJ Round 2 Saturday 4pm UTC (it&#8217;s 1pm here in Brazil, right?!)! Coming Soon: GSoC Status Update (I promise!!!)]]></description>
			<content:encoded><![CDATA[<p>Just to update my blog, let&#8217;s get ready to GCJ Round 2 <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Saturday 4pm UTC (it&#8217;s 1pm here in Brazil, right?!)!</p>
<p>Coming Soon: GSoC Status Update (I promise!!!) <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brunogola.com.br/2008/07/google-code-jam-round-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyPy 2.5-features &#8211; Yet another status update</title>
		<link>http://blog.brunogola.com.br/2008/07/pypy-25-features-yet-another-status-update/</link>
		<comments>http://blog.brunogola.com.br/2008/07/pypy-25-features-yet-another-status-update/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 03:27:29 +0000</pubDate>
		<dc:creator>Bruno Gola</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[pypy]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[magic number]]></category>
		<category><![CDATA[opcodes]]></category>
		<category><![CDATA[pyc]]></category>
		<category><![CDATA[pycode]]></category>
		<category><![CDATA[status update]]></category>

		<guid isPermaLink="false">http://blog.brunogola.com.br/?p=44</guid>
		<description><![CDATA[Here comes another GSoC status update Some finished tasks: throw() method on generators close() method&#8230; faking 2.5 behavior for IMPORT_NAME and IMPORT_FROM opcodes changing the default value for magic attribute of PyCode objects changing the magic number that goes in .pyc files compiled by PyPy fixing tests and more tests&#8230; From those changes the only [...]]]></description>
			<content:encoded><![CDATA[<p>Here comes another GSoC status update <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Some finished tasks:</p>
<ul>
<li>throw() method on generators</li>
<li>close() method&#8230;</li>
<li>faking 2.5 behavior for IMPORT_NAME and IMPORT_FROM opcodes</li>
<li>changing the default value for <em>magic </em> attribute of PyCode objects</li>
<li>changing the magic number that goes in .pyc files compiled by PyPy</li>
<li>fixing tests and more tests&#8230;</li>
</ul>
<p>From those changes the only one I would like to comment is the change of both magic numbers. </p>
<p>First, they have different values and meanings in PyPy. The magic number for .pyc files (defined in <em>pypy/modules/__builtin__/importing.py</em>) is the number that identifies the bytecode &#8220;version&#8221;. It&#8217;s used to know if the interpreter should use the .pyc file or should recompile the .py. PyPy&#8217;s value is different from CPython&#8217;s one. As we are changing some opcodes (as IMPORT_NAME, mentioned before) this number had to be changed. The old value in PyPy was 1024 (or 1024 + 2 or 1024 + 4 or 1024 + 2 + 4, depending on some command line options), the new value is 1034 (or &#8230;.). We are just using the same policy CPython uses to change the value, add 10 to the old value.</p>
<p>Now the PyCode <em>magic</em> attribute. This value is the CPython magic number (the one explained above)., the old default value was the value from CPython 2.4 (62021). Some checks against this value are made through the code to decide if the bytecode should be interpreted one way or another. One example is the IMPORT_NAME opcode. In Python 2.4 IMPORT_NAME did not have the level parameter, this parameter is new in 2.5 because of the <em>absolute import</em> feature. So if the bytecode represented by a PyCode object is 2.4, when we visit a <em>import</em> statement we should not try to pop the level value from the stack (because it&#8217;s not there), but if it is 2.5 we should! So we check the magic value. The problem is, the default value was 2.4 but we changed the opcodes to behave like 2.5, so those checks were not working. The solution was to change the magic default value to 63231 (2.5c2 value I think), so now our bytecode interpreter is (almost?) compatible with 2.5 bytecode. And our compiler is generating 2.5 compatible bytecode as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brunogola.com.br/2008/07/pypy-25-features-yet-another-status-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyPy 2.5-features &#8211; PyParser, Grammar and PEPs</title>
		<link>http://blog.brunogola.com.br/2008/07/pypy-25-features-pyparser-grammar-and-peps/</link>
		<comments>http://blog.brunogola.com.br/2008/07/pypy-25-features-pyparser-grammar-and-peps/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 16:08:13 +0000</pubDate>
		<dc:creator>Bruno Gola</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[pypy]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[peps]]></category>

		<guid isPermaLink="false">http://blog.brunogola.com.br/?p=41</guid>
		<description><![CDATA[After two weeks without any writing, here comes another status update of my GSoC (and I promise I&#8217;ll do it more frequently). Today I&#8217;m working on PEP 342 &#8211; &#8220;Coroutines via Enhanced Generators&#8221;. I&#8217;ve finished to implement the .send() method and all the stuff it should do &#8220;behind the scenes&#8221; (e.g. push the value into [...]]]></description>
			<content:encoded><![CDATA[<p>After two weeks without any writing, here comes another status update of my GSoC (and I promise I&#8217;ll do it more frequently).</p>
<p>Today I&#8217;m working on PEP 342 &#8211; &#8220;Coroutines via Enhanced Generators&#8221;. I&#8217;ve finished to implement the <em>.send()</em> method and all the stuff it should do &#8220;behind the scenes&#8221; (e.g. push the value into the frame stack).</p>
<p>Last week some other PEPs and small changes were supported as well. </p>
<p>PEPs 308 (conditional expressions) and 343 (with statement) were already supported, I just needed to write tests and remove a SyntaxWarning for conditional expressions. PEP 352 (BaseException and raise &#8220;string&#8221;) is now supported as well.</p>
<p>Some changes were made to Grammar2.5 because pyparser could not read it the right way. Those changes were already present to Grammar2.4. The main problem is that when the parser finds a rule that has alternatives (like, &#8216;is&#8217; | &#8216;is&#8217; &#8216;not&#8217; ) and the first alternative matches (imagine it trying to match &#8216;is not&#8217;, it will match &#8216;is&#8217;) it doesn&#8217;t look for the other alternatives and then fails (because there is no rule that matches a &#8216;not&#8217; after an &#8216;is&#8217;). The solution in that case is to change the order (which doesn&#8217;t make much sense, before looking the parser&#8217;s code), so the rule should be &#8216;is&#8217; &#8216;not&#8217; | &#8216;is&#8217;.</p>
<p>Next steps: check PyCode magic number and finish PEP 342 <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brunogola.com.br/2008/07/pypy-25-features-pyparser-grammar-and-peps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ImportWarning, UnicodeWarning, -W and parser</title>
		<link>http://blog.brunogola.com.br/2008/06/importwarning-unicodewarning-w-and-parser/</link>
		<comments>http://blog.brunogola.com.br/2008/06/importwarning-unicodewarning-w-and-parser/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 22:55:18 +0000</pubDate>
		<dc:creator>Bruno Gola</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[pypy]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[pyparser]]></category>
		<category><![CDATA[warnings]]></category>

		<guid isPermaLink="false">http://blog.brunogola.com.br/?p=38</guid>
		<description><![CDATA[After almost three weeks (more?) I&#8217;m back Well, this week I&#8217;ve fixed two small 2.5 features in PyPy. The first one was UnicodeWarning. From Python&#8217;s docs: &#8230;UnicodeWarning is triggered when you attempt to compare a Unicode string and an 8-bit string that can&#8217;t be converted to Unicode using the default ASCII encoding&#8230; In PyPy to [...]]]></description>
			<content:encoded><![CDATA[<p>After almost three weeks (more?) I&#8217;m back <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Well, this week I&#8217;ve fixed two small <a href="/?p=36">2.5 features</a> in PyPy. </p>
<p>The first one was <em>UnicodeWarning</em>. From <a href="http://docs.python.org/whatsnew/other-lang.html">Python&#8217;s docs</a>:</p>
<blockquote><p>&#8230;UnicodeWarning is triggered when you attempt to compare a Unicode string and an 8-bit string that can&#8217;t be converted to Unicode using the default ASCII encoding&#8230;</p></blockquote>
<p>In PyPy to trigger a Warning when in Interpreter-level you can use the method <em>space.warn</em>, this method, internally, will use the <em>warnings</em> module to trigger the warning properly.</p>
<p>The second was <em>ImportWarning</em>. Again from <a href="http://docs.python.org/whatsnew/other-lang.html">Python&#8217;s docs</a>:</p>
<blockquote><p>ImportWarning warning is triggered when an import would have picked up a directory as a package but no __init__.py was found</p></blockquote>
<p>After searching for a while I&#8217;ve found the pypy/lib/__buitins__/importing.py file that holds, obviously, pypy importing stuff. I&#8217;ve looked to CPython&#8217;s implementation to see when I should trigger the ImportWarn and <em>load_part()</em> seemed to be the right place.</p>
<p>The ImportWarning should be silently ignored unless you provide the -Wd command line option but PyPy does not accept the -W option, so I&#8217;ve implemented it. It is simple, you just need to append the argument (&#8216;d&#8217; in this case) to the sys.warnoptions list. </p>
<p>While working on this issues I&#8217;ve found a bug in the parser when using the 2.5 Grammar. It is raising a SyntaxError when you call a function passing a keyword argument (like f(x=3)). Because of this (and other small bugs) I&#8217;ve decided that I will work on the pyparser to make it compatible with the 2.5 Grammar now.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brunogola.com.br/2008/06/importwarning-unicodewarning-w-and-parser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GSoC officially starting</title>
		<link>http://blog.brunogola.com.br/2008/05/gsoc-officially-starting/</link>
		<comments>http://blog.brunogola.com.br/2008/05/gsoc-officially-starting/#comments</comments>
		<pubDate>Mon, 26 May 2008 04:42:58 +0000</pubDate>
		<dc:creator>Bruno Gola</dc:creator>
				<category><![CDATA[personal]]></category>
		<category><![CDATA[gsoc]]></category>

		<guid isPermaLink="false">http://blog.brunogola.com.br/?p=37</guid>
		<description><![CDATA[Well, It&#8217;s already May 26 here and following the official Google Summer of Code 2008 calendar the coding for GSoC has officially started. So let&#8217;s code.. I wish that all students to have a good summer of code.]]></description>
			<content:encoded><![CDATA[<p>Well, It&#8217;s already May 26 here and following the official Google Summer of Code 2008 calendar the coding for GSoC has officially started.</p>
<p>So let&#8217;s code.. <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I wish that all students to have a good summer of code.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brunogola.com.br/2008/05/gsoc-officially-starting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyPy 2.5 features &#8211; news</title>
		<link>http://blog.brunogola.com.br/2008/05/pypy-25-features-news/</link>
		<comments>http://blog.brunogola.com.br/2008/05/pypy-25-features-news/#comments</comments>
		<pubDate>Tue, 13 May 2008 04:14:59 +0000</pubDate>
		<dc:creator>Bruno Gola</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[pypy]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[bytecode]]></category>
		<category><![CDATA[compilers]]></category>
		<category><![CDATA[google summer of code]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[parser]]></category>

		<guid isPermaLink="false">http://blog.brunogola.com.br/?p=35</guid>
		<description><![CDATA[Changes! Now I&#8217;m free to work &#8220;full-time&#8221; on my GSoC project, last Friday was my last day on my old job (Ikwa) Today I&#8217;ve read lots of docs and code, specially the pyparser code. I&#8217;ll try to maintain a list of features I&#8217;m currently working on here. Last week (ok, Friday before last Friday) we [...]]]></description>
			<content:encoded><![CDATA[<p>Changes! Now I&#8217;m free to work &#8220;full-time&#8221; on my GSoC project, last Friday was my last day on my old job (<a href="http://www.ikwa.com.br">Ikwa</a>) <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Today I&#8217;ve read lots of docs and code, specially the pyparser code. I&#8217;ll try to maintain a list of features I&#8217;m currently working on <a href="http://blog.brunogola.com.br/?page_id=36">here</a>. </p>
<p>Last week (ok, Friday before last Friday) <a href="http://blog.brunogola.com.br/?p=33">we went to Werneck&#8217;s cave</a> to code. One thing I&#8217;ve made there was implement the <em>defaultdict</em> object in the <em>collections</em> module. This module is written in C originally, so I needed to port it.</p>
<p>The code is relatively simple and I&#8217;ve just &#8220;copied&#8221; the C implementation (of course it&#8217;s  clearer and more beautiful in Python <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ). <a href="http://diaspar.blogspot.com">Werneck</a> also helped me with the pyparser but we couldn&#8217;t find a solution for supporting the full Python 2.5 Grammar .</p>
<p>Today I&#8217;ve worked on a small Python 2.5 change, the empty base classes list syntax.</p>
<p>Until Python 2.5 the list of base classes could not be empty. So you couldn&#8217;t define a class like:</p>
<pre>
class A():
    pass
</pre>
<p>The right way for doing this was </p>
<pre>
class A:
    pass
</pre>
<p>Now, in Python 2.5, both ways are legal.</p>
<p>Last week I&#8217;ve committed  a slight changed Grammar for Python 2.5 syntax support to <a href="http://codespeak.net/svn/pypy/branch/2.5-features">PyPy&#8217;s 2.5-features branch</a> (the only change I&#8217;ve made was removing the support for the new import syntax, as it crashes the parser, I need to work on that).</p>
<p>With part of the 2.5 Grammar already supported, to support this new class definition syntax the only change needed was in pyparser (more specifically to the <a href="http://en.wikipedia.org/wiki/Abstract_Syntax_Tree">AST</a> builder).</p>
<p>While the <em>build_classdef</em> method expected 4 atoms (<em>< class keyword ></em>, <em>< white space ></em>, <em>< class name ></em> and <em>< comma ></em>) or 7 (the same 4 plus <em>< ( ></em>, <em>< base classes ></em> and <em>< ) ></em> before the <em>< comma ></em>) in Python 2.4, now in Python 2.5 it can receive 6 atoms too (<em>< class keyword ></em>, <em>< white space ></em>, <em>< class name ></em>, <em>< ( >, < ) ></em> and <em>< comma ></em>). The change was really simple, but it was a good exercise for me because I could apply what I&#8217;m learning in my <strong>compilers</strong> classes at school (while reading the sources) <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Some code (pypy/interpreter/pyparser/astbuilder.py:634):</p>
<pre>
def build_classdef(builder, nb):
    ...
    if l == 4: # class NAME:
        basenames = []
        body = atoms[3]
    elif l == 6: # class NAME():  # 2.5
        basenames = []
        body = atoms[5]
    else:
        assert l == 7
        basenames = []
        body = atoms[6]
        base = atoms[3]
    ...
</pre>
<p>I don&#8217;t think I need to explain this code, it&#8217;s very simple (of course, it&#8217;s Python! <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> ).</p>
<p>I&#8217;ve made some tests and it seemed to work great, but I&#8217;ve decided to compare the bytecode generated by PyPy and by CPython (both 2.4 and 2.5). While in CPython 2.4 the statement &#8220;class A: pass&#8221; produces the following bytecode:</p>
<pre>
>>> from dis import dis; c = compile("class A: pass", "/dev/null", "exec"); dis(c)
  1           0 LOAD_CONST               0 ('A')
              3 BUILD_TUPLE              0
              6 LOAD_CONST               1 (<code object A at 0xb7d11f60, file "/dev/null", line 1>)
              9 MAKE_FUNCTION            0
             12 CALL_FUNCTION            0
             15 BUILD_CLASS
             16 STORE_NAME               0 (A)
             19 LOAD_CONST               2 (None)
             22 RETURN_VALUE
</pre>
<p>CPython 2.5 produces for both statements (the old syntax and the new one) something slight different:</p>
<pre>
>>> from dis import dis; c = compile("class A: pass", "/dev/null", "exec"); dis(c)
  1           0 LOAD_CONST               0 ('A')
              3 LOAD_CONST               3 (())
              6 LOAD_CONST               1 (<code object A at 0xb7d8cf50, file "/dev/null", line 1>)
              9 MAKE_FUNCTION            0
             12 CALL_FUNCTION            0
             15 BUILD_CLASS
             16 STORE_NAME               0 (A)
             19 LOAD_CONST               2 (None)
             22 RETURN_VALUE
</pre>
<p>The only difference between 2.4 and 2.5 is the instruction BUILD_TUPLE in 2.4 against the LOAD_CONST in 2.5. I'm not a bytecode expert, but it seems that this is an optimization, of course I may be completely wrong <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  </p>
<p>Well, as I expected the bytecode produced by PyPy is identical the one produced by CPython 2.4, so I think I have more things to change to complete this task. <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>But not tonight, after 14 hours of PyPy code reading and some debugging (plus Linear Programming  and Computer Theory classes) I think I should sleep.</p>
<p> <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brunogola.com.br/2008/05/pypy-25-features-news/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Python friends meeting</title>
		<link>http://blog.brunogola.com.br/2008/05/python-friends-meeting/</link>
		<comments>http://blog.brunogola.com.br/2008/05/python-friends-meeting/#comments</comments>
		<pubDate>Mon, 05 May 2008 19:50:19 +0000</pubDate>
		<dc:creator>Bruno Gola</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[defaultdict]]></category>
		<category><![CDATA[google summer of code]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[pypy]]></category>
		<category><![CDATA[sushi]]></category>

		<guid isPermaLink="false">http://blog.brunogola.com.br/?p=33</guid>
		<description><![CDATA[Last Friday, me, Luciano Pacheco and Marcelo Honório went to Pedro Werneck&#8216;s house (or werneck&#8217;s cave) to talk, eat and, of course, code python We wrote a small guide (portugues only, sorry&#8230; I promise i&#8217;Il translate it to English) about preparing the environment for those who want to participate of the PythonBugDay (or even for [...]]]></description>
			<content:encoded><![CDATA[<p>Last Friday, me, <a href="http://lucmult.wordpress.com">Luciano Pacheco</a> and <a href="http://www.marcelohonorio.com.br">Marcelo Honório</a> went to  <a href="http://diaspar.blogspot.com">Pedro Werneck</a>&#8216;s house (or werneck&#8217;s cave) to talk, eat and, of course, code python <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>We wrote a <a href="http://www.pythonbrasil.com.br/moin.cgi/PythonBugDay/ComoSePreparar">small guide</a> (portugues only, sorry&#8230; I promise i&#8217;Il translate it to English) about preparing the environment for those who want to participate of the PythonBugDay (or even for the curious who want to play with the cpython code). </p>
<p>Of course I&#8217;ve worked on my GSoC project implementing the new (2.5) &#8220;defaultdict&#8221; object  (in the collections module), but this is subject of another post <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Werneck and Pacheco also worked on some issues/bugs listed in the CPython bugtracker and I&#8217;ve introduced them to PyPy (and vice-versa hehe).</p>
<p>After all this coding we ate Japanese food and our friend <a href="http://www.andrewsmedina.com/">Andrews</a> suggested a new kind of development method, Sushi-Driven Development&#8230; nice! <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brunogola.com.br/2008/05/python-friends-meeting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyPy 2.5 features: __hash__ behavior</title>
		<link>http://blog.brunogola.com.br/2008/04/pypy-25-features-__hash__-behavior/</link>
		<comments>http://blog.brunogola.com.br/2008/04/pypy-25-features-__hash__-behavior/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 06:37:08 +0000</pubDate>
		<dc:creator>Bruno Gola</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[pypy]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[gsoc]]></category>

		<guid isPermaLink="false">http://blog.brunogola.com.br/?p=27</guid>
		<description><![CDATA[One small change in Python 2.5 is the __hash__ method behavior. In earlier versions the __hash__ method was supposed to return a normal integer always, but now due to changes in the id() builtin function the __hash__ method behavior was changed and it can return a long or an int. This was easy to change [...]]]></description>
			<content:encoded><![CDATA[<p>One <a href="http://docs.python.org/whatsnew/other-lang.html">small change</a> in Python 2.5 is the <em>__hash__</em> method behavior. In earlier versions the <em>__hash__</em> method was supposed to return a normal integer always, but now due to changes in the <em>id()</em> builtin function the <em>__hash__</em> method behavior was changed and it can return a <em>long</em> or an <em>int</em>.</p>
<p>This was easy to change in PyPy, the <em>hash()</em> builtin function implementation is part of the <a href="http://codespeak.net/pypy/dist/pypy/doc/objspace.html">ObjectSpace</a> as almost all the builtin functions and types.</p>
<p>It&#8217;s in pypy/objspace/descroperation.py:</p>
<pre name="code" class="python">
def hash(space, w_obj):
        w_hash = space.lookup(w_obj, '__hash__')
        if w_hash is None:
            if space.lookup(w_obj, '__eq__') is not None or \
               space.lookup(w_obj, '__cmp__') is not None:
                raise OperationError(space.w_TypeError,
                                     space.wrap("unhashable type"))
            return default_identity_hash(space, w_obj)
        w_result = space.get_and_call_function(w_hash, w_obj)
        if space.is_true(space.isinstance(w_result, space.w_int)):
            return w_result
        else:
            raise OperationError(space.w_TypeError,
                     space.wrap("__hash__() should return an int or long"))
</pre>
<p>One don&#8217;t even need to know PyPy well to understand that the lines</p>
<pre name="code" class="python">
if space.is_true(space.isinstance(w_result, space.w_int)):
    return w_result
else:
    raise OperationError(space.w_TypeError,
             space.wrap("__hash__() should return an int or long"))
</pre>
<p>are responsible for raising a <em>TypeError</em> when the returning value from __hash__ is not an integer.</p>
<p>So just changing the condition </p>
<pre name="code" class="python">
space.is_true(space.isinstance(w_result, space.w_int)):
</pre>
<p>to</p>
<pre name="code" class="python">
(space.is_true(space.isinstance(w_result, space.w_int)) or
 space.is_true(space.isinstance(w_result, space.w_long))):
</pre>
<p>will solve this, I hope!</p>
<p>But that&#8217;s not all the code needed, I promised Carl to write tests for everything, but as I like to use TDD (test-driven development) it was already done.</p>
<p>Oh, and should I mention that I love PyPy&#8217;s documentation? Thanks guys!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brunogola.com.br/2008/04/pypy-25-features-__hash__-behavior/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Supporting Python 2.5 features in PyPy &#8211; GSoC 2008</title>
		<link>http://blog.brunogola.com.br/2008/04/supporting-python-25-features-in-pypy-gsoc-2008/</link>
		<comments>http://blog.brunogola.com.br/2008/04/supporting-python-25-features-in-pypy-gsoc-2008/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 19:31:35 +0000</pubDate>
		<dc:creator>Bruno Gola</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[pypy]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[google summer of code]]></category>
		<category><![CDATA[gsoc]]></category>

		<guid isPermaLink="false">http://blog.brunogola.com.br/?p=24</guid>
		<description><![CDATA[As you probably know my GSoC proposal to work on PyPy interpreter, supporting the Python 2.5 features, has been accepted. This post is a short explanation of my Google Summer of Code project. PyPy The PyPy project aims at producing a flexible and fast Python implementation. The guiding idea is to translate a Python-level description [...]]]></description>
			<content:encoded><![CDATA[<p>As you probably know my GSoC proposal to work on PyPy interpreter, <a href="http://code.google.com/soc/2008/psf/appinfo.html?csaid=ED41878DC5E619B2">supporting the Python 2.5 features</a>, has <a href="/?p=23">been accepted</a>. This post is a short explanation of my Google Summer of Code project.</p>
<p><strong>PyPy</strong></p>
<blockquote><p>
The PyPy project aims at producing a flexible and fast Python implementation. The guiding idea is to translate a Python-level description of the Python language itself to lower level languages. Rumors have it that the secret goal is being faster-than-C which is nonsense, isn&#8217;t it?
</p></blockquote>
<p><a href="http://codespeak.net/pypy">PyPy</a> is divided into the python interpreter and the translator framework. The interpreter is written in RPython (a subset of Python) and the main goal is to provide an easy-to-hack (for python programmers <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ) Python interpreter.</p>
<p>PyPy&#8217;s interpreter currently supports only a few features <a href="http://docs.python.org/whatsnew/whatsnew25.html">introduced in Python 2.5</a>, like __index__ (for slicing) and some part of the &#8216;with&#8217; statement.  Also, the 2.5 changes to the language and to the standard library have not been ported yet (although some have been, like the ctypes).</p>
<p><strong>Goal</strong></p>
<p>This proposal idea is to bring Python 2.5 features and changes to PyPy interpreter, this includes porting the modules and writing code for the features it self.</p>
<p>Here are some of the features I&#8217;ll work on:</p>
<ul>
<li>PEP 308: Conditional Expressions[*]</li>
<li>328: Absolute and Relative Imports</li>
<li>PEP 342: New Generator Features</li>
<li>PEP 343: The with statement[*]</li>
<li>PEP 352: Exceptions as New-Style Classes</li>
</ul>
<p>[*] <em>part of this features are already supported by PyPy</em></p>
<p><strong>Benefits</strong></p>
<p>With support to 2.5 features and changes more the PyPy interpreter will be up-to-date so people who wants to use this features can be happy using PyPy. This probably means more people using PyPy (i hope!)  <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>Why this project?</strong></p>
<p>The first reason I&#8217;ve chosen the PyPy project is that I really like their ideas and goals. I was looking for collaborating to it in some way for a long time, but it took me some time to read the docs and to really understand the project.</p>
<p>As I like PyPy ideas and I&#8217;m starting to plan my graduation project/bachelor&#8217;s thesis, my work on PyPy interpreter will be a big part of it. Maybe I can explain my ideas in another post <img src='http://blog.brunogola.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I would like to thank Google (and the SoC folks), Python Software Foundation, PyPy and specially to <a href="http://morepypy.blogspot.com">Carl Friedrich Bolz</a>* who will be my GSoC mentor and Leonardo Santagada who helped me to understand PyPy and to write my application.</p>
<p><em>* <a href="http://morepypy.blogspot.com">morepypy</a> is a blog where PyPy developers talk to the community, it&#8217;s not Carl&#8217;s personal blog.</em></p>
<p>Thanks to my friends from <a href="http://www.pythonbrasil.com.br">Python Brasil</a> community too.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brunogola.com.br/2008/04/supporting-python-25-features-in-pypy-gsoc-2008/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

