<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Frederik De Bleser</title>
 
 <link href="http://enigmeta.com/" />
 <updated>2009-06-19T08:21:34-07:00</updated>
 <id>http://enigmeta.com/</id>
 <author>
   <name>Frederik De Bleser</name>
   <email>frederik@pandora.be</email>
 </author>

 
 <link rel="self" href="http://feeds.feedburner.com/enigmeta" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry>
   <title>PyCon 2009 report</title>
   <link href="http://enigmeta.com/2009/04/15/pycon-2009-report.html" />
   <updated>2009-04-15T00:00:00-07:00</updated>
   <id>http://enigmeta.com/2009/04/15/pycon-2009-report</id>
   <content type="html">&lt;h1&gt;PyCon 2009 report&lt;/h1&gt;


	&lt;p class="meta"&gt;15 Apr 2009 &amp;#8211; Antwerp&lt;/p&gt;


	&lt;p&gt;This year was my first visit to &lt;a href="http://www.pycon.org/"&gt;PyCon&lt;/a&gt; in the United States. Here&amp;#8217;s the &lt;a href="http://us.pycon.org/2009/conference/schedule/"&gt;full schedule for the conference&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;In this post, I will give some notes and remarks about the sessions that I followed. For each session I included a link to the session details. Most of them have videos and slides of the talks.&lt;/p&gt;


	&lt;h2&gt;How to Give a Python talk&lt;/h2&gt;


	&lt;p&gt;A lot of talk about presentations using slides. I don&amp;#8217;t like slides. The author didn&amp;#8217;t like live coding because you could make a lot of typos, which would frustrate an audience. Later on, somebody gave a lightning talk about &lt;a href="http://code.google.com/p/playerpiano/"&gt;player piano&lt;/a&gt;, a project that types automatically for you and is very useful for presentations.&lt;/p&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/6/"&gt;How to Give a Python talk&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Introduction to CherryPy&lt;/h2&gt;


	&lt;p&gt;CherryPy is a lightweight &lt;span class="caps"&gt;HTTP&lt;/span&gt; framework. It is very much unlike Django: it doesn&amp;#8217;t have an &lt;span class="caps"&gt;ORM&lt;/span&gt; or administrative interface, but just provides the perfect balance for creating web applications that are different from the standard &lt;a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete"&gt;&lt;span class="caps"&gt;CRUD&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;You can install &amp;#8220;tools&amp;#8221; that can, for example, automatically encode/decode &lt;span class="caps"&gt;JSON&lt;/span&gt;. CherryPy-guy gave a nice example that I can&amp;#8217;t find, but here&amp;#8217;s &lt;a href="http://www.cherrypy.org/wiki/CustomTools"&gt;the webpage&lt;/a&gt;.&lt;/li&gt;
		&lt;li&gt;You can use &lt;a href="http://www.cherrypy.org/wiki/PageHandlers"&gt;other dispatchers&lt;/a&gt; than the default. MethodDispatcher looks interesting, because it allows you to do &lt;span class="caps"&gt;REST&lt;/span&gt;-style systems.&lt;/li&gt;
		&lt;li&gt;There&amp;#8217;s a tool to &lt;a href="http://www.cherrypy.org/wiki/StaticContent"&gt;serve static content&lt;/a&gt;.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/11/"&gt;Introduction to CherryPy&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Introduction to Python Profiling&lt;/h2&gt;


	&lt;p&gt;Tools for how to write fast Python code.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;You need to profile your code to find out where it spends its time. This is really important: you really don&amp;#8217;t know where your code is slow.&lt;/li&gt;
		&lt;li&gt;Use &lt;a href="http://docs.python.org/library/profile.html"&gt;cProfile&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://kcachegrind.sourceforge.net/html/Home.html"&gt;KCacheGrind&lt;/a&gt; can help you with interpreting Python profiles.&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://www.vrplumber.com/programming/runsnakerun/"&gt;RunSnakeRun&lt;/a&gt; allows you to view cProfile dumps in a &lt;span class="caps"&gt;GUI&lt;/span&gt;. This tool was created by the guy giving the talk.&lt;/li&gt;
		&lt;li&gt;Caching function references can speed up deeply nested code. But profile first.&lt;/li&gt;
		&lt;li&gt;Property lookups look just like an attribute lookup, but can be much slower.&lt;/li&gt;
		&lt;li&gt;Another interesting tool is &lt;a href="http://packages.python.org/line_profiler/"&gt;line profiler&lt;/a&gt;, by Robert Kern of Enthought.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/15/"&gt;Introduction to Python Profiling&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Panel: Python VMs&lt;/h2&gt;


	&lt;p&gt;A discussion about the different implementations of Python:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;CPython, the &amp;#8220;official&amp;#8221; Python implementation. This gets confused with Python, because a few years ago there was only one Python language and implementation. Now there are  many implementations of the same language.&lt;/li&gt;
		&lt;li&gt;Jython, Python on the &lt;span class="caps"&gt;JVM&lt;/span&gt;.&lt;/li&gt;
		&lt;li&gt;IronPython, Python on .NET and Mono.&lt;/li&gt;
		&lt;li&gt;PyPy, Python in Python. This is actually more useful than it sounds.&lt;/li&gt;
		&lt;li&gt;Unladen swallow, an effort by Google to make Python 10x faster.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;What I found interesting in the discussion was that the &amp;#8220;official&amp;#8221; Python guys really welcome and support the other implementations. I had a chance to have lunch together with all the different VM guys, and they are really sincere about this.&lt;/p&gt;


	&lt;p&gt;Just as with JavaScript implementations, there is a lot of buzz and activity around making Python run faster. Python and JavaScript are very different languages however, and optimization techniques used in JavaScript cannot be used in Python. Still, everybody has their own idea of how to make Python faster (check out &amp;#8220;PyPy status&amp;#8221;).&lt;/p&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/21/"&gt;Panel: Python VMs&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Python in a sandbox&lt;/h2&gt;


	&lt;p&gt;A talk by the makers of PyPy about the use of PyPy as a virtualization tool. PyPy has a secure sandbox for running untrusted Python code, where you can bound IO calls, &lt;span class="caps"&gt;CPU&lt;/span&gt; and &lt;span class="caps"&gt;RAM&lt;/span&gt; resources. Really interesting for running other peoples&amp;#8217; Python code on your own server. PyPy is &amp;#8220;only&amp;#8221; 2-3 times slower than regular Python.&lt;/p&gt;


	&lt;p&gt;There is no official release, but here are the steps for running it yourself:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Download the &lt;a href="http://codespeak.net/svn/user/getxsick/django-sandbox/"&gt;sandbox&lt;/a&gt;.&lt;/li&gt;
		&lt;li&gt;Translate pypy with&amp;#8212;sandbox flag (this takes a while).&lt;/li&gt;
		&lt;li&gt;Run the script using pypy interact.py&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/27/"&gt;Python in a sandbox&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;A better Python for the &lt;span class="caps"&gt;JVM&lt;/span&gt;&lt;/h2&gt;


	&lt;p&gt;A &lt;strong&gt;very&lt;/strong&gt; technical talk about the Jython compiler. A bit over my head. However the conclusions were:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Currently Jython is a bit slower than Python.&lt;/li&gt;
		&lt;li&gt;The new Jython compiler should make things a bit faster.&lt;/li&gt;
		&lt;li&gt;However, currently the new compiler isn&amp;#8217;t faster.&lt;/li&gt;
		&lt;li&gt;But it provides better opportunities for optimization.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/32/"&gt;A better Python for the &lt;span class="caps"&gt;JVM&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Behind the scenes of EveryBlock.com&lt;/h2&gt;


	&lt;p&gt;Adrian Holovaty, maker of Django, talked about Everyblock, his project to catalog everything that&amp;#8217;s happening at the hyper-local level (in your neighborhood).&lt;/p&gt;


	&lt;p&gt;They have a lot of different data-types, and wanted to store all of them in the same table. This meant that date types had to be opaque, since the columns would be different for the various datatypes. The main table has columns named varchar1, varchar2, int1, int2, etc. A schema table defines what these various columns means for a given schema.&lt;/p&gt;


	&lt;p&gt;This really looked like a hack, which was surprising coming from Adrian, someone who has written such a clean web framework. It seems like an other database system (such as key-value stores or even a graph database, such as &lt;a href="http://neo4j.org/"&gt;neo4j&lt;/a&gt;) would fit the job better.&lt;/p&gt;


	&lt;p&gt;One remark also struck me as odd: Adrian stated that he wrote everything from scratch, basically because &amp;#8220;I don&amp;#8217;t trust other people&amp;#8217;s code&amp;#8221;. It was unclear whether he was entirely serious or not, but the fact remains that no external code was used in his website.&lt;/p&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/36/"&gt;Behind the scenes of EveryBlock.com&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Jython Progress&lt;/h2&gt;


	&lt;p&gt;The reason for coming to PyCon: a very interesting talk by &lt;a href="http://fwierzbicki.blogspot.com/"&gt;Frank Wierzbicki&lt;/a&gt;, who works at Sun on Jython.&lt;/p&gt;


	&lt;p&gt;The focus for the Jython 2.5 release was on compatibility. Through our use with Jython we found that a lot of stuff that worked in Python really worked in Jython as well, which was nice.&lt;/p&gt;


	&lt;p&gt;The focus for Jython 2.6 will be on performance and integration with Java. It should show up quicker than the 2.2 &amp;gt; 2.5 release, which took years to complete.&lt;/p&gt;


	&lt;p&gt;At the end he also showed &lt;a href="http://www.openendedgroup.com/field"&gt;Field&lt;/a&gt;, which is a Processing/NodeBox-like environment in Java using Jython. It has only very recently been open-sourced. It only runs on Mac &lt;span class="caps"&gt;OS X 10&lt;/span&gt;.5.&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://us.pycon.org/2009/conference/schedule/event/46/"&gt;Jython Progress&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Pinax: a platform for rapidly developing websites&lt;/h2&gt;


	&lt;p&gt;Pinax has been getting some exposure lately because it provides ready-made components for Django. I had some troubles getting it to work, and was hoping this talk would provide some answers.&lt;/p&gt;


	&lt;p&gt;There seemed to be some problems with how to distribute this, and how to version all of it. They make a lot of use of svn:externals, which isn&amp;#8217;t bad per se. It really requires a lot of commitment to get started with the framework, but once you have it installed, it provides a lot of the boilerplate functionality of sites, and more specifically, social networks: user-to-user messaging, twitter clone, tagging, photo management, interest groups, ... .&lt;/p&gt;


	&lt;p&gt;After the talk, I&amp;#8217;m still not sure if it&amp;#8217;s worth the trouble, or if I&amp;#8217;d rather be writing a lot of that from scratch. I feel the framework is still a bit too young to be used without to much configuration hassle. Also, the remark of Adrian during his EveryBlock talk about writing everything himself rings true here.&lt;/p&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/49/"&gt;Pinax: a platform for rapidly developing websites&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Class Decorators: Radically Simple&lt;/h2&gt;


	&lt;p&gt;A nice introduction to &amp;#8220;better metaclasses&amp;#8221;. The functionality is only available in Python 2.6, but the talk is interesting (and short) enough to watch in its entirety.&lt;/p&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/55/"&gt;Class Decorators: Radically Simple&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;PyPy status talk&lt;/h2&gt;


	&lt;p&gt;After the talk about Python sandboxing using PyPy, I was interested in what the status of PyPy was as a project. PyPy was started to be able to generate Python interpreters with more flexibility than a fixed C implementation. By defining a Python Interpreter on a higher level, you can experiment with different VM features quickly.&lt;/p&gt;


	&lt;p&gt;The PyPy interpreter is slower but consumes a lot less memory: some objects are 50% the size of CPython. They don&amp;#8217;t support libraries written in C, but they do support CTypes as the official way to have bindings for PyPy.&lt;/p&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/59/"&gt;PyPy status talk&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Drop &lt;span class="caps"&gt;ACID&lt;/span&gt; and think about data&lt;/h2&gt;


	&lt;p&gt;&lt;a href="http://bob.pythonmac.org/"&gt;Bob Ippolito&lt;/a&gt; talked about the various alternative data storage implementations that have come up recently. He covered both closed- and open-source implementations. Most of the talk was about alternative key-value stores and other non-relational models, but he didn&amp;#8217;t cover graph databases.&lt;/p&gt;


	&lt;p&gt;There are a lot of different kinds of databases out there, but none of them seemed particularly stable or usable for my purposes. Afterwards, I checked out the open space about Cassandra, which seemed like the most stable one.&lt;/p&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/64/"&gt;Drop &lt;span class="caps"&gt;ACID&lt;/span&gt; and think about data&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Concurrency and Distributed Computing with Python Today&lt;/h2&gt;


	&lt;p&gt;This talk was not so much about the multiprocessing module in Python 2.6, but more about the tools available today.&lt;/p&gt;


	&lt;p&gt;He covered Jython as a solution for the global interpreter lock (GIL), because Jython uses Java threading which does not have the &lt;span class="caps"&gt;GIL&lt;/span&gt;. Also, the usage of java.util.concurrent solves a lot of problems. Actually, this seemed the most interesting approach for my projects.&lt;/p&gt;


	&lt;p&gt;He also talked about &lt;a href="http://www.stackless.com/"&gt;Stackless Python&lt;/a&gt;, which offers lightweight threads and cooperative multitasking.&lt;/p&gt;


	&lt;p&gt;There are different approaches to multitasking:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Real threads: hard to use because concurrency requires a lot of thinking ahead. They are hampered by the &lt;span class="caps"&gt;GIL&lt;/span&gt; in CPython.&lt;/li&gt;
		&lt;li&gt;Coroutines: light-weight threads are not truly parallel, but simplify the threading problem.&lt;/li&gt;
		&lt;li&gt;Actors: isolated, self reliant components that communicate via messages. They are truly parallel, and are a good model to overcome the threading fallacies. &lt;a href="http://erlang.org/"&gt;Erlang&lt;/a&gt; and &lt;a href="http://www.scala-lang.org/"&gt;Scala&lt;/a&gt; are two programming languages that use the actors idiom for concurrency.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;All of these approaches have libraries implementing them in Python. There are a &lt;strong&gt;lot&lt;/strong&gt; of them, and most are alpha quality. The two good ones are &lt;a href="http://twistedmatrix.com/trac/"&gt;Twisted&lt;/a&gt; and &lt;a href="http://www.kamaelia.org/Home"&gt;Kamaelia&lt;/a&gt;. The rest is a mish-mash of technologies. (&amp;#8220;Concurrency is hard, let’s go shopping!&amp;#8221;)&lt;/p&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/69/"&gt;Concurrency and Distributed Computing with Python Today&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Abstraction as Leverage&lt;/h2&gt;


	&lt;p&gt;An abstract talk about the tower of abstractions we use every as programmers, and how to produce and consume abstraction layers.&lt;/p&gt;


	&lt;p&gt;The starting point for the talk was that abstractions &amp;#8220;leak&amp;#8221;. This is something &lt;a href="http://www.joelonsoftware.com/articles/LeakyAbstractions.html"&gt;Joe Spolsky&lt;/a&gt; has written about, and an interesting read. He also pointed out a quote from Jason Fried of 37 signals: &amp;#8220;Prefer action over abstr-action&amp;#8221;.&lt;/p&gt;


	&lt;p&gt;It&amp;#8217;s hard to sum up the talk without paraphrasing it (badly), so I suggest you go see it.&lt;/p&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/75/"&gt;Abstraction as Leverage&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Paver: easy build and deployment automation for Python projects&lt;/h2&gt;


	&lt;p&gt;&lt;a href="http://www.blueskyonmars.com/projects/paver/"&gt;Paver&lt;/a&gt; is sort of like &lt;a href="http://ant.apache.org/"&gt;Ant&lt;/a&gt; for Python projects, but instead of using a bizarre &lt;span class="caps"&gt;XML&lt;/span&gt;
syntax, just using Python. It is also very similar to Ruby&amp;#8217;s &lt;a href="http://rake.rubyforge.org/"&gt;Rake&lt;/a&gt;. It is really
interesting and looks mature. It requires you to make a pavement.py file in your project
directory that gets picked up and executed by Paver.&lt;/p&gt;


	&lt;p&gt;The basic building blocks in Paver are tasks. Tasks can be given command options (using &lt;a href="http://docs.python.org/library/optparse.html"&gt;optparse&lt;/a&gt; -like syntax).&lt;/p&gt;


	&lt;p&gt;Paver can be used for deploying servers, generating documentation, building a distribution
(using distutils/setuptools), working with files, etc. Paver doesn&amp;#8217;t replace distutils, but
embraces and extends it in a non-evil way.&lt;/p&gt;


	&lt;p&gt;A good introduction is &lt;a href="http://www.blueskyonmars.com/projects/paver/getting_started.html"&gt;Getting Starting with Paver&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/82/"&gt;Paver: easy build and deployment automation for Python projects&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Making games in Python &amp;#8211; Tools and techniques at &lt;span class="caps"&gt;CCP&lt;/span&gt;&lt;/h2&gt;


	&lt;p&gt;I wanted to see this talk to see how a gaming company used Python almost everywhere in a high-profile &lt;span class="caps"&gt;MMORPG&lt;/span&gt;. They use Python for networking, the web server, content authoring tools (using wxPython) and game logic. Some performance-critical parts were they use C+&lt;ins&gt;. They did not talk about how they wrapped C&lt;/ins&gt;+ code, only that they didn&amp;#8217;t use Boost.Python.&lt;/p&gt;


	&lt;p&gt;They use embedded &lt;a href="http://www.stackless.com/"&gt;stackless Python&lt;/a&gt;, which they actively maintain. It allows them to do micro-threading (every object in the world runs in its own light-weight thread).&lt;/p&gt;


	&lt;p&gt;They use their own code-reloading system called &lt;a href="http://code.google.com/p/livecoding/"&gt;livecoding&lt;/a&gt; because the reload built-in was deemed unsuitable. Their custom code reloading system allows them to reload game code while server and client are running. They also integrated unit testing so that the tests run before the code is reloaded to see if it passes.&lt;/p&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/87/"&gt;Making games in Python &amp;#8211; Tools and techniques at &lt;span class="caps"&gt;CCP&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Stackless python in &lt;span class="caps"&gt;EVE&lt;/span&gt;, pt. 2&lt;/h2&gt;


	&lt;p&gt;This talk went more in depth about how they used Stackless Python in &lt;span class="caps"&gt;EVE&lt;/span&gt;. It covered
StacklessIO, a unified framework for blocking operations in Stackless Python. He also talked
about how they deployed StacklessIO at &lt;span class="caps"&gt;CCP&lt;/span&gt;, using &amp;#8220;Cowboy mode&amp;#8221;, which short-circuited normal
QA procedures. Although interesting, I could not see myself using any of the technologies or
working methods introduced.&lt;/p&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/91/"&gt;Stackless python in &lt;span class="caps"&gt;EVE&lt;/span&gt;, pt. 2&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Designing a web framework: Django&amp;#8217;s design decisions&lt;/h2&gt;


	&lt;p&gt;I love to see Jacob Kaplan-Moss give a talk, and this one was no exception. This talk was high-level overview of some of the design decisions they made in the framework, and how to keep ego out of the equation.&lt;/p&gt;


	&lt;p&gt;He talked about the difference between academic frameworks (&amp;#8220;architecture astronauts&amp;#8221;) and the real world.&lt;/p&gt;


	&lt;p&gt;What I found interesting was the decision in Django to make a full stack framework instead of glueing together existing components. Part of the reason for this was that there were not much existing components available, but also that they could provide one consistent &lt;span class="caps"&gt;API&lt;/span&gt;
dialect that felt they same, whether you were working in the templating language, the database &lt;span class="caps"&gt;API&lt;/span&gt; or some other part of the stack.&lt;/p&gt;


	&lt;p&gt;He also pointed that out that having users pick from existing components because it would allow for full flexibility only makes sense for expert users, and not for beginners that are just starting out with your framework. Having them pick from a list of components that they have no knowledge over is silly.&lt;/p&gt;


	&lt;p&gt;He also pointed out the talk by Cal Henderson of Flickr, &lt;a href="http://www.youtube.com/watch?v=i6Fr65PFqfk"&gt;Why I Hate Django&lt;/a&gt; which is really interesting and funny.&lt;/p&gt;


	&lt;p&gt;&amp;raquo; &lt;a href="http://us.pycon.org/2009/conference/schedule/event/95/"&gt;Designing a web framework: Django&amp;#8217;s design decisions&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Open Space: Cassandra&lt;/h2&gt;


	&lt;p&gt;I followed an open space talk by Jonathan Ellis of Rackspace Managed Hosting, one of the maintainers of Cassandra. &lt;a href="http://code.google.com/p/the-cassandra-project/"&gt;Cassandra&lt;/a&gt; is a distributed database somewhere between &lt;a href="http://en.wikipedia.org/wiki/BigTable"&gt;BigTable&lt;/a&gt; and &lt;a href="http://www.allthingsdistributed.com/2007/10/amazons_dynamo.html"&gt;Dynamo&lt;/a&gt;, which are both closed source. The project was started by two ex-Googlers at Facebook, and has now been open-sourced. The talk went into depth about the implementation of Cassandra.&lt;/p&gt;


	&lt;p&gt;The system looks interesting but way too big for my needs. As long as we don&amp;#8217;t really need high-performance distributed databases, I&amp;#8217;d prefer my &lt;span class="caps"&gt;ACID&lt;/span&gt; using MySQL or Postgresql (or Neo4j).&lt;/p&gt;


	&lt;h2&gt;Neo4j&lt;/h2&gt;


	&lt;p&gt;Turns out the maker of the new Jython compiler also works on an open-source graph database called &lt;a href="http://neo4j.org/"&gt;neo4j&lt;/a&gt;. His name is &lt;a href="http://twitter.com/thobe"&gt;Tobias Ivarsson&lt;/a&gt;.  I talked to him and showed him &lt;a href="http://nodebox.net/code/index.php/Perception"&gt;Perception&lt;/a&gt;. He was convinced that neo4j would be perfect for this: super-fast, O(1) lookups, lightweight, &lt;a href="http://components.neo4j.org/neo4j.py/"&gt;Python bindings&lt;/a&gt;. It is a mature graph database that runs in production for over 5 years.&lt;/p&gt;


	&lt;p&gt;There are &lt;a href="http://components.neo4j.org/"&gt;components&lt;/a&gt; available for indexing, graph algorithms and much more.&lt;/p&gt;


	&lt;h2&gt;Answered questions&lt;/h2&gt;


	&lt;p&gt;I came to the conference to hear talks about the progress and future of Jython. I am now convinced that Jython is an excellent choice for Python development, given that there are some very motivated people working on it, and they have the full support of the CPython guys.&lt;/p&gt;


	&lt;h2&gt;Unanswered questions&lt;/h2&gt;


	&lt;p&gt;One thing I&amp;#8217;ve been struggling with in NodeBox is how to do proper packaging of NodeBox packages. I need a system that can version packages, do dependency management, can run several version of the same package at the same time, and do live loading/unloading of packages. I recently discovered &lt;a href="http://www.osgi.org/Main/HomePage"&gt;OSGi&lt;/a&gt; recently, which seems to solve this problem for Java. However, Python doesn&amp;#8217;t seem to have a system like that available. There was a lot of talk about &lt;a href="http://pypi.python.org/pypi/virtualenv"&gt;virtualenv&lt;/a&gt;, &lt;a href="http://pypi.python.org/pypi/pip"&gt;pip&lt;/a&gt; and even &lt;a href="http://pypi.python.org/pypi/zc.buildout"&gt;zc.buildout&lt;/a&gt;, but none of those seems to provide a complete answer. (By the way, Jacob&amp;#8217;s recent &lt;a href="http://jacobian.org/writing/django-apps-with-buildout/"&gt;blog post about zc.buildout&lt;/a&gt; is very interesting.) The whole environment seems very much in flux, and I think we&amp;#8217;ll have to wait for the next PyCon to have an answer available.&lt;/p&gt;


	&lt;p&gt;Personally, I would love to see integration between the VM&amp;#8217;s native package management system and the Python implementation (for Jython, that would be OSGi). However, even OSGi seems to come under attack, as Sun is &lt;a href="http://www.osgi.org/blog/2007/07/can-someone-tell-sun-about-osgi.html"&gt;rolling its own solution&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Overall, package management is a hairy business, and one that needs some serious thought. As for now, I think I&amp;#8217;m better off taking a good hard look at OSGi and then rolling my own solution.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>My Favourite Python hack</title>
   <link href="http://enigmeta.com/2009/03/27/my-favourite-python-hack.html" />
   <updated>2009-03-27T00:00:00-07:00</updated>
   <id>http://enigmeta.com/2009/03/27/my-favourite-python-hack</id>
   <content type="html">&lt;h1&gt;My Favourite Python hack&lt;/h1&gt;


	&lt;p class="meta"&gt;27 Mar 2009 &amp;#8211; Chicago&lt;/p&gt;


	&lt;p&gt;In &lt;a href="http://nodebox.net/"&gt;NodeBox&lt;/a&gt;, we have this cool feature that we call &amp;#8220;the throttle&amp;#8221;. It allows you to interactively drag any number in the (Python) script and see the results immediately. Whether it&amp;#8217;s and X/Y coordinate, the number in &amp;#8220;for i in range(10)&amp;#8221;, or a number in a complicated formula, just dragging the number helps you visualize the effect of it on the overall composition. Here&amp;#8217;s a movie that demonstrates how this works:&lt;/p&gt;


&lt;object width="400" height="300"&gt;&lt;param name="allowfullscreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3907211&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=&amp;amp;fullscreen=1" /&gt;&lt;embed src="http://vimeo.com/moogaloop.swf?clip_id=3907211&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=&amp;amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"&gt;&lt;/embed&gt;&lt;/object&gt;

	&lt;p&gt;Today I&amp;#8217;d like to talk about the implementation, which works like this:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Find the character under the cursor.&lt;/li&gt;
		&lt;li&gt;Expand until you get the full number (include digits, periods and minus signs)&lt;/li&gt;
		&lt;li&gt;Replace it with &lt;i&gt;magic_var&lt;/i&gt; and add this variable to the locals dictionary&lt;/li&gt;
		&lt;li&gt;When the user &amp;#8220;drags&amp;#8221; the number, replace the value of &lt;i&gt;magic_var&lt;/i&gt; with an updated value and run the script again.&lt;/li&gt;
		&lt;li&gt;When the user releases the mouse, replace the old number in the source file with the new number.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Sounds simple, right? While this approach worked well in 90% of the cases, it broke down when the signs of the number changes from positive to negative or vice versa. Here are the three use cases:&lt;/p&gt;


* If an addition goes from positive to negative the sign should change:
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mf"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
* If a subtraction goes from negative to positive the sign should change as well:
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mf"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
* &lt;strong&gt;But&lt;/strong&gt; if a negative number turns positive, the sign should disappear:
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;

	&lt;p&gt;The difficulty was in finding the difference between the first case and the third case. After a lot of dabbling around with regular expressions, I suddenly had an insight. There is actually a Python module that handles this problem: the Python parser itself.&lt;/p&gt;


	&lt;p&gt;When Python parses the code, it builds an abstract syntax tree (AST), a tree-like representation of the code. Different nodes are represented by classes in the compiler.ast module. The use cases above are represented by instance of Sub (a two-part subtraction), UnarySub (a negative number), and Addition (a two-part addition).&lt;/p&gt;


	&lt;p&gt;Note that we replaced the original number with the name &lt;i&gt;magic_var&lt;/i&gt; in our original source code, and compiled that. After compilation succeeds and returns an &lt;span class="caps"&gt;AST&lt;/span&gt;, a function called _checkSigns recursively checks the &lt;span class="caps"&gt;AST&lt;/span&gt; for special sign cases. First, it tries to find the magic variable. Once it has found that, it checks the parent node to see if it encounters any of the special cases, and basically prepares the object for string replacement afterwards.&lt;/p&gt;


	&lt;p&gt;What I like about this hack is that if it works correctly, you don&amp;#8217;t even notice it&amp;#8217;s there.&lt;/p&gt;


	&lt;p&gt;If you&amp;#8217;d like to view the code, it&amp;#8217;s in the NodeBox source as &lt;a href="http://dev.nodebox.net/browser/nodebox/trunk/src/nodebox/gui/mac/ValueLadder.py"&gt;ValueLadder.py&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Revealing movie credits</title>
   <link href="http://enigmeta.com/2009/03/12/revealing-movie-credits.html" />
   <updated>2009-03-12T00:00:00-07:00</updated>
   <id>http://enigmeta.com/2009/03/12/revealing-movie-credits</id>
   <content type="html">&lt;h1&gt;Revealing movie credits&lt;/h1&gt;


	&lt;p class="meta"&gt;12 Mar 2009 &amp;#8211; Antwerp&lt;/p&gt;


	&lt;p&gt;I think it is funny how some movies reveal everything there is to know about them, just by looking at the movie credits. Not even the actors, just the roles they play:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Crack head 1&lt;/li&gt;
		&lt;li&gt;Elegant woman&lt;/li&gt;
		&lt;li&gt;Crackhead 2&lt;/li&gt;
		&lt;li&gt;Mass Appeal Editor&lt;/li&gt;
		&lt;li&gt;Woman in closet&lt;/li&gt;
		&lt;li&gt;Crackwhore&lt;/li&gt;
		&lt;li&gt;Shower Girl&lt;/li&gt;
		&lt;li&gt;Dealer&lt;/li&gt;
		&lt;li&gt;Tom&lt;/li&gt;
		&lt;li&gt;High-school girl&lt;/li&gt;
		&lt;li&gt;Perfect Urban Gentleman&lt;/li&gt;
		&lt;li&gt;Pool Player&amp;#8217;s Homie&lt;/li&gt;
		&lt;li&gt;High-school girl 1&lt;/li&gt;
		&lt;li&gt;Junkyard slut&lt;/li&gt;
		&lt;li&gt;Junkyard stud&lt;/li&gt;
		&lt;li&gt;Woman on couch&lt;/li&gt;
		&lt;li&gt;Porn Model&lt;/li&gt;
		&lt;li&gt;Hooker&lt;/li&gt;
		&lt;li&gt;Shitkicker&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;The movie, if you&amp;#8217;re still interested, is called &lt;a href="http://www.imdb.com/title/tt0974977/"&gt;Bad Biology&lt;/a&gt;. I haven&amp;#8217;t seen it yet, but judging by the credits and the synopsis talking about the woman with 9 clitorises (clitorii?), I probably should.&lt;/p&gt;</content>
 </entry>
 
 
</feed>
