<?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>Mike&#039;s Blabberings &#187; pycon</title>
	<atom:link href="http://www.mike-griffith.com/blog/tag/pycon/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mike-griffith.com/blog</link>
	<description>on software, testing, and the web.</description>
	<lastBuildDate>Tue, 29 Jun 2010 14:37:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Notes from PyCon 2009</title>
		<link>http://www.mike-griffith.com/blog/2009/03/notes-from-pycon-2009/</link>
		<comments>http://www.mike-griffith.com/blog/2009/03/notes-from-pycon-2009/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 21:24:56 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[software development]]></category>
		<category><![CDATA[pycon]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.mike-griffith.com/blog/?p=299</guid>
		<description><![CDATA[Just wrapping up a fantastic few days at PyCon Chicago 2009.  I went with a group of about 10 guys from AGI, and we managed to have a little bit of fun in between some great mind-enriching talks.
Here are some notes I jotted down while at the conference.  It&#8217;s a bit overwhelming, but [...]]]></description>
			<content:encoded><![CDATA[<p>Just wrapping up a fantastic few days at <a href="http://us.pycon.org/2009/about/">PyCon Chicago 2009</a>.  I went with a group of about 10 guys from <a href="http://www.aginteractive.com">AGI</a>, and we managed to have a little bit of fun in between some great mind-enriching talks.</p>
<p>Here are some notes I jotted down while at the conference.  It&#8217;s a bit overwhelming, but I wanted to throw this out there for now, then I&#8217;ll come back and reorganize it.</p>
<p><strong>Tutorial: PyCon 401 &#8211; Some Advanced Topics, by Steve Holden</strong><br />
 * String interpolation<br />
 * Iterators<br />
 * Generators<br />
 * Descriptors and name lookups<br />
 * Metaclasses</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
String Interpolation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Can use locals() trick</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> fmt<span style="color: black;">&#40;</span>date, x<span style="color: black;">&#41;</span>:
    amount = <span style="color: #ff4500;">3</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;%(date)12s $(x)-25s %(amount)8.2f&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: #008000;">locals</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Iteration<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Iterable object must have next() and __iter__()<br />
 * next returns next item, or raises StopIteration<br />
 * __iter__ returns an &#8220;iterable&#8221; object (e.g. self)</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Generators<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Any function with &#8220;yield&#8221; in it is automagically assumed to be a generator by<br />
the compiler<br />
 * Never actually return anything<br />
 * Obey the iterator protocol, and thus have a next() method</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> g<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>:
  <span style="color: #ff7700;font-weight:bold;">for</span> c <span style="color: #ff7700;font-weight:bold;">in</span> s:
    <span style="color: #ff7700;font-weight:bold;">yield</span> c+<span style="color: #483d8b;">'!'</span>
g1 = g<span style="color: black;">&#40;</span><span style="color: #483d8b;">'hello'</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">assert</span> <span style="color: black;">&#91;</span>c <span style="color: #ff7700;font-weight:bold;">for</span> c <span style="color: #ff7700;font-weight:bold;">in</span> g1<span style="color: black;">&#93;</span> == <span style="color: black;">&#91;</span><span style="color: #483d8b;">'h!'</span>, <span style="color: #483d8b;">'e!'</span>, <span style="color: #483d8b;">'l!'</span>, <span style="color: #483d8b;">'l!'</span>, <span style="color: #483d8b;">'o!'</span><span style="color: black;">&#93;</span></pre></div></div>

<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Decorators and other cool shit<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>functools.wrap<br />
 * when making a decorator, decorate your decorator with this to preserve<br />
   &#8220;dunder_name&#8221; __name__ and dunder-doc __doc__</p>
<p>functools.partial<br />
 * copy a function to a new place and provide different kwarg defaults</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Descriptors and Properties<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>HACKATTACK: Property definition without namespace polluion<br />
 * see ~/src/sandbox/src/pycon/tests/test_property.py</p>
<p>Descriptor protocol just talks about how to look up stuff in a class<br />
 * not all that cool :-/</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Metaclasses<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>factories<br />
 * produce and return functions<br />
 * produce and return classes</p>
<p>metaclass<br />
 * can do cool shit to a class without cluttering up the class definition<br />
 * keep your classes closer to application domain model and responsibilities</p>
<p>Example metaclass: Automagically Decorate Every Method in Class<br />
 * page 35 of notes defines a Tracer class factory with __new__, that wraps<br />
   every callable, non-dundered (__x__) function with a tracing decorator<br />
 * you add a __metaclass__ attribute to your class, then when it gets spun up,<br />
   the tracer factory decorates its shit<br />
 * see ~/src/sandbox/src/pycon/tests/test_metaclass.py</p>
<p><strong>Notes from Friday</strong></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Windmill<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
in-browser, cross-browser functional testing framework<br />
 * started as fork of selenium<br />
 * great visual recorder<br />
 * dom inspector cross-browser<br />
python api<br />
continuous integration w/ hudson<br />
reporting hooks<br />
issues:<br />
 * no ssl support</p>
<p>http://www.getwindmill.com</p>
<p>LOOKS AWESOME!</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Profiling<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Optimization makes code harder to maintain<br />
But necessary sometimes because Python is slow in real world<br />
Premmature optimization is the root of all evil.  Forget about small efficiencies.  Focus on hot spots.<br />
Improve your algorithms for the 3% of worst things<br />
 * unroll loop<br />
 * add caching<br />
Use profiling to figure out which pieces are the 3%</p>
<p>track entry and exit times to functions using Timer</p>
<p>How to:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> cProfile
cProfile.<span style="color: black;">run</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;python.swallow(gopher)&quot;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>? pstats.Stats(&#8216;1.profile&#8217;, &#8216;2.profile&#8217;)<br />
** not good for threaded systems&#8230; need seperate profiler per thread</p>
<p>KCacheGrind can help explore profile output (runs on wxpython)</p>
<p>Look for<br />
 * way too many calls<br />
 * large local time in single function (can be spot-optimized)<br />
 * large cumulative per call (possibly cache results)<br />
 * high waiting times (IO blocked ?)</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Testing AJAX Web Apps<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
It&#8217;s hard, and Kumar has failed.  This is just an overview of what has/hasn&#8217;t worked.</p>
<p>Example: pylons+dojo aintjustsoul.net<br />
 * ajax to fetch album thumbnails</p>
<p>Strategy:<br />
    &#8211; test data handlers (in python)<br />
    &#8211; test javascript<br />
        &#8211; lint it first for syntax errors (e.g. javascriptlint.com)<br />
        &#8211; rhino runner (perhaps with john resig&#8217;s env.js to simulate DOM)<br />
        &#8211; spidermonkey ?<br />
        &#8211; Selenium, jquery.simulate, YUI.test to simulate user events in browser<br />
    (now it gets trickier)<br />
    &#8211; isolate UI for testing<br />
        &#8211; DI your connection stuff to mock out data and use a fake server, at the<br />
          cost of a little more indirection<br />
    &#8211; automate UI tests<br />
        &#8211; selenium remote control automates browser interactions via python code<br />
    &#8211; gridify your tests<br />
        &#8211; &#8220;selenium grid&#8221; to speed up tests<br />
        &#8211; future: test swarm<br />
           &#8211; crowd sourced continuous integration<br />
            &#8211; seems like an awful security flaw</p>
<p><a href="http://bit.ly/testing-ajax">http://bit.ly/testing-ajax</a> (mailing list on google groups)</p>
<p>JSBridge can help to launch firefox from terminal<br />
 * it fakes X-server so mozilla runs but doesn&#8217;t put anything to display<br />
 * you can still run your tests in an actual browser rather than rhino&#8217;s implementation<br />
 * mozilla ubiquity plugin tested this way</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Auomated QA Infrastructure<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Ingredients:<br />
 * VCS<br />
    &#8211; mainline branch.. merges trigger full QA battery<br />
    &#8211; devs use QA system on dev branches<br />
 * reporting<br />
    &#8211; if you don&#8217;t do this, nothing else matters<br />
    &#8211; &#8220;your QA system is ONLY as good as its reporting of results&#8221;<br />
 * tests (discovery, coverage metrics, static source analysis, performance profiling)<br />
    &#8211; discovery = nose<br />
    &#8211; coverage = figleaf<br />
    &#8211; static analysis = pylint<br />
    &#8211; profiling = ????</p>
<p>CI frameworks:<br />
 * svnchecker (svn post-commit hooks)<br />
 * bitten<br />
 * pybots<br />
 * buildbot ***** <-- best general purpose python-based open-source framework now</p>
<p>Buildbot Architecture<br />
 * master: coordinate, dispatch, report<br />
 * build slaves: runs tests as directed<br />
    - BuildFactory defines the build process<br />
    >>> factory.addStep(SVN(url))<br />
    >>> factory.addStep(Compile(command=['python', 'setup.py', 'build'])<br />
    >>> factory.addStep(nose.run()) #????<br />
            # they used Trial(testpath=&#8217;.') for Twisted<br />
    >>> factory.addStep(Figleaf(&#8230;<br />
    >>> factory.addStep(PyLint(&#8230;<br />
 * changes: encapsulates events that require testing<br />
 * schedulers: makes decisions about when/where to order tests<br />
 * pollers/triggers: signals the base change events<br />
    &#8211; built-in SVNPoller</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Twisted/MQ/RPC<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&#8230; (notes in moleskin) &#8230;</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Testing large, untested codebases<br />
~ Titus<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Example: biological something or other<br />
on the science background of code under test<br />
 * example: pygr &#8211; python graph database<br />
    &#8211; provides data abstration with pygr.Data<br />
 * problem in biology<br />
    &#8211; tons and tons of data, parsed lists, etc</p>
<p>on the code and authors<br />
 * da code<br />
    &#8211; ~8k of Py, ~2k of Pyrex<br />
    &#8211; almost all library and framework, no UI fluff<br />
 * the people<br />
    &#8211; written by 1 dude ==> lots of technical debt<br />
        &#8211; no tests, interface contracts, etc.<br />
    &#8211; code ownership is issue by new people that want to contribute.<br />
      don&#8217;t want to step on original author&#8217;s code<br />
    &#8211; idiosyncratic code since author was a smart dude</p>
<p>statement: code coverage is of limited utility bc it doesn&#8217;t measure branch coverage<br />
 * TITUS SAYS WRONG WRONG WRONG<br />
 * it&#8217;s not just bc it doesn&#8217;t measure branch coverage.  there are other more<br />
   valid reasons why it might be flawed</p>
<p>grokking code through coverage<br />
 * howto:<br />
     &#8211; given a big chunk o python<br />
     &#8211; import it, write test to exercise some of it, check coverage to see what it done<br />
     &#8211; add additional statement to test<br />
     &#8211; repeat<br />
 * lets you pull apart highly complex/coupled code<br />
 * </p>
<p>problem: no good way keep track of tests in a large codebase<br />
 * some things may or may not be getting run by your runner<br />
 * new project &#8220;tattle&#8221; that keeps track of master list of tests<br />
    &#8211; when running, checks the master list and if something is missing or new, it warns you<br />
    &#8211; not decided how to keep track of what&#8217;s changed<br />
        &#8211; yaml ?<br />
        &#8211; tag the source ?<br />
        &#8211; check the diff ?  (requires &#8220;saving&#8221; coverage state, then comparing on next run)</p>
<p>&#8220;for those that use nose, each additional dot is like another hit of smack&#8221;</p>
<p>code review:<br />
 * pep8<br />
 * pep257 &#8211; docstring format!!!</p>
<p>&#8220;each time you&#8217;ve pissed on another line of code, it&#8217;s like it&#8217;s yours now&#8221;</p>
<p>reformatting vs &#8220;search/replace&#8221; vs real functional changes<br />
 * what you gonna break?</p>
<p>coverage is an invaluable lever for prying into other people&#8217;s code bases</p>
<p>what&#8217;s next?<br />
 * trace code coverage between commits (and which lines are no longer covered)<br />
 * branch coverage (titus on GSoC project: &#8220;i have no idea how to do this, that&#8217;s what students are for&#8221;)<br />
 * simplify CI.  buildbot too complex</p>
<p><strong>Notes from Saturday</strong></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
!!!! LIGHTNING TALKS !!!!<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>== thestatusisnotquo.com ==<br />
@mpirnat&#8217;s socially redeeming python mini-community of hackers</p>
<p>== sqlpython ==<br />
write sql in unix command shell<br />
have access to all other cool unix stuff (grep, sed, cat, etc)</p>
<p>== webob ==<br />
presentation was cool&#8230; just played through the doctests in a<br />
fake interactive interpreter.  flawless demo FTW!</p>
<p>== DVCS ==<br />
mercurial (hg) is super easy to use<br />
statement: hg on bitbucket is better than svn on google code<br />
successful DVCS don&#8217;t really use the D<br />
but django 1.1 delayed by a month because of DVCS crap<br />
what&#8217;s the benefit:<br />
 * better merging (but shouldn&#8217;t require DVCS)<br />
 * easier repository creation (as opposed to svnadmin)<br />
svn isn&#8217;t quite dead yet (but it&#8217;s not getting better)</p>
<p>== pymite ==<br />
python on microcontrollers.. runs on 8bit devices with 64kb ram<br />
easily embed native code in docstrings</p>
<p>== web2py ==<br />
MVC web framework.  used for pycon registration.<br />
online DB admin tool ala django<br />
online python code editor<br />
integrates with bug ticketing system and links back to original stack trace<br />
templating system looks like advanced pyfusion</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Guido&#8217;s keynote<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
py3.1/2.7 coming<br />
no decision on dvcs<br />
tool to backport from py3 to py2 coming.  then we can write code in 3 and give it to the 2x world also.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
State of Django<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&#8230; (see moleskin) &#8230;</p>
<p>** statement: everyone should be using sphinx for technical docs **</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Lack of Design Patterns<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&#8220;python isn&#8217;t java without the compile&#8221;</p>
<p>define lack of patterns:<br />
 * comp.lang.python 100k messages<br />
 * visitor/flyweight/strategy/state pattern was most often referenced<br />
   (but still less than &#8220;sausage&#8221;)</p>
<p>why no talk of patterns?<br />
 * patterns are built-in<br />
    &#8211; first class functions<br />
    &#8211; metaprogramming (can manipulate functions/definitions)<br />
    &#8211; iterators<br />
    &#8211; closures (even if not a &#8220;true&#8221; closure in python, but close enough)</p>
<p>examples:<br />
 * factory<br />
   >>> {&#8216;thing1&#8242;:Thing1, &#8216;thing2&#8242;:Thing2}[which_one]()</p>
<p>conclusions:<br />
 * look to features of langauge before patterns<br />
 * reduce patterns &#8211;> shortercode<br />
 * if need a pattern, add a language feature (e.g. concurrency stuff)</p>
<p>presentor wants &#8220;channel pattern&#8221; (as a model for processes to replace threads)<br />
 * look at PyCSP (or stackless?) for concurrency</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Class Decorators<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>just like function decorators<br />
 * definition: a callable that accepts at least one argument and returns something</p>
<p>available as of py2.6</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> identity<span style="color: black;">&#40;</span>ob<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> ob 
&nbsp;
@identiy
<span style="color: #ff7700;font-weight:bold;">class</span> C<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">pass</span></pre></div></div>

<p>in 2.5, you can do same type of thing, but you can&#8217;t use the @decorator syntax</p>
<p>class decorators are not inheritable!!!<br />
but you can stack them on top of a single class<br />
(as opposed to metaclasses, which are inherited but not stackable)</p>
<p>default method decorator vs. mixins (eg partial class)<br />
 * ???</p>
<p>popular patterns (besides just replacing what was done with metaclasses)<br />
 * register<br />
 * augment (mixin replacement)<br />
    &#8211; example: take the __lt__ method and automagically make an __eq__ and<br />
      __gt__ for class<br />
 * fixup (monkeypatching decorator)<br />
    &#8211; example: replace all dunder-attribute with single underscores, so can get<br />
      access to the stuff that was privatized.  can monkeypatch a decorator into<br />
      a thirdparty library too!  (named @stop_doing_java)<br />
 * verify (assert stuff about the class)</p>
<p>registration pattern<br />
 * presentors best use case<br />
 * add stuff to a list that&#8217;s kept elsewhere</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">@cron.<span style="color: black;">schedule</span><span style="color: black;">&#40;</span>cron.<span style="color: black;">NIGHTLY</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">class</span> SalesReport<span style="color: black;">&#40;</span>Report<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> run<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #808080; font-style: italic;">#blah</span></pre></div></div>

<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
ORM Panel<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&#8230;</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Scripting in Python (super beginner)<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Compromise Layout pattern<br />
    Project<br />
        /bin<br />
            script.py<br />
        /scriptlib<br />
            __init__.py<br />
            scriptimpl.py<br />
        setup.py<br />
Conditional main pattern<br />
    >>> if __name__ == &#8216;main&#8217;:<br />
    &#8230;    sys.exit(main(sys.argv))<br />
3 layers of IO pattern:<br />
 * should you deal with filenames, file objects, or generators ?  YES!<br />
 * main should take a filename.  invokes something that takes a file instanece.<br />
   below that use generator layer for efficiency.<br />
Use optparse pattern<br />
wtf.  not exactly what i was expecting from this talk.  time to go drink.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Drop ACID and think about data<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
ACID: a promise ring your DBMS wears<br />
 * atomicity &#8211; all or nothing<br />
 * consistency &#8211; no explosions during crashes/etc<br />
 * isolation &#8211; no fighting from writers, can pretend transactions are serial<br />
 * durability &#8211; no lying to you.. assume things worked</p>
<p>scalability and reliability: requires a bunch of stuff from rdbms to get there</p>
<p>CAP theorem says pick 2:<br />
 * consistency, availability, partition tolerance</p>
<p>BASE:<br />
 * basically available, soft state (doesn&#8217;t have to be consistent immediately), eventually consistent<br />
 * Google BigTable<br />
    &#8211; append-only data makes it faster to insert<br />
    &#8211; fantastic data compression due to hybrid row/column storage<br />
 * Amazon Dynamo key/value store<br />
    &#8211; consistent hashing to distribute data to appropriate node<br />
 * Facebook Cassandra<br />
    &#8211; OPEN SOURCE!!  incrementally scalable<br />
    &#8211; no compression, not quite polished <img src='http://www.mike-griffith.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>distributed db&#8217;s are the new hotness, but none are awesome yet.<br />
 * we don&#8217;t need another half-baked dynamo clone</p>
<p>memcached: key/value store used as cache<br />
 * RAM only.  throws data away.  lightning fast.  everyone&#8217;s doing it.<br />
 * invalidation is hard and failure-prone<br />
    &#8211; be careful with mutable data.  consistency will be lost over DB solution.</p>
<p>Tokyo Cabinet/Tyrant:  super enhanced berkeleydb key/value store<br />
 * disk persistent, but still very performant<br />
 * actively developed<br />
 * replication similar to mysql<br />
!! possible solution for photoworks session</p>
<p>document databases<br />
 * schema free, easy to use,<br />
 * easier to migrate.  some documents will just have different properties.<br />
    &#8211; but application still needs to be able to deal with this<br />
!! we kind of got this with photoworks project meta-data<br />
 * couchdb &#8211; document db poster child<br />
 * mongodb &#8211; way faster than couchdb.  json/bson (binary json-ish)</p>
<p>column databases:<br />
 * sequential reads are awesome<br />
 * compresses much better than rows<br />
 * monetdb &#8211; DON&#8217;T USE THIS</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Concurrency and Distributed systems<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
concurrent > parallel > distributed</p>
<p>goals:<br />
 * decrease latency, increase throughput</p>
<p>issue?<br />
 * global interpreter lock (GIL).  one thread at a time.<br />
    &#8211; ugh. slow. boo.<br />
    &#8211; perhaps fixed in unladen-swallow ?<br />
 * but you can build concurrent regardless of GIL</p>
<p>multiprocessing in 2.6+<br />
 * processes and IPC via pipes to allow parallelism<br />
 * similar API to thread/queue</p>
<p>more on GIL workarounds&#8230;<br />
 * Jython<br />
    &#8211; allows free-threading via java.util.concurrent, at the cost of losing C extensions<br />
 * IronPy<br />
    &#8211; also unrestricted threading, and some C extensions via ironclad<br />
 * PyPy<br />
    &#8211; complete rethink of interpreter<br />
    &#8211; not production ready <img src='http://www.mike-griffith.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Twisted<br />
 * asynchronous, event driven multitasking<br />
 * supports thread usage, but may not always be threadsafe</p>
<p>Kamaelia<br />
 * easy to understand.  very easy to get up and running.  IPCs, Threads, etc abstracted away<br />
 * compontents talk vis mailbox.  cooperative multitasking via generators<br />
 * lots of fantastic examples<br />
 !!! try this out</p>
<p>problem w/ frameworks<br />
 * twisted/kamaelia radically different<br />
 * you end up adapting the methodology in app, which can be dangerous</p>
<p>messaging/rpc flooded with libraries<br />
 * Pyro for RPC should be checked out<br />
 * memcached for shared memory<br />
 * Stomp, ApacheActiveMQ for message queues<br />
    &#8211; space flooded b/c heavy use by web apps for asynch processesing right now</p>
<p><strong>Notes from Sunday</strong></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Paver<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
build process helpers<br />
 * cmd line<br />
 * config<br />
 * work w/ files<br />
 * svn, sphinx, virtualenv, etc.<br />
 * distutils, setuptools</p>
<p>without paver, you end up writing a seperate script for everything you want to do</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ easy_install Paver
$ paver paverdocs <span style="color: #666666; font-style: italic;">#displays Paver documentation</span></pre></div></div>

<p>build files&#8230;<br />
$ vi pavement.py</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">options<span style="color: black;">&#40;</span>
    setup = setup_meta,  <span style="color: #808080; font-style: italic;">#via setup.py</span>
    virtualenv=Bunch<span style="color: black;">&#40;</span>
        packages_to_install=<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;&quot;</span>, <span style="color: #483d8b;">&quot;&quot;</span>, <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#93;</span>,
...</pre></div></div>

<p>tasks are the heart of paver</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">@task
<span style="color: #ff7700;font-weight:bold;">def</span> clean<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
   <span style="color: #483d8b;">&quot;&quot;&quot; cleans up paver dict,  removes virtualenv tree and build dir &quot;&quot;&quot;</span></pre></div></div>

<p>other fun decorators too<br />
@cmdopts &#8211; integration w/ optparser to set up cmd line options for your tasks</p>
<p>paver.easy<br />
 * logging, unix command running, dry-run stuff against command line</p>
<p>paver.path<br />
 * jason orendorff&#8217;s path.py module built in</p>
<p>paver.doctools<br />
 * sphinx (generate html docs)<br />
 * ned batch&#8217;s Cog support.  &#8220;section off&#8221; pieces of code and pull into your docs dynamically.</p>
<p>paver.ssh, paver.svn, paver.virtual (virtualenv)</p>
<p>deployment of code delegated to pytoss (?)</p>
<p>getting started: http://bit.ly/starting_paver</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Functional Testing Panel<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
windmill<br />
 * python proxy &#8211; avoids same domain security in browser<br />
 * python browser launching<br />
 * python CI reporting<br />
 * javascript simulate user interactions &#8211; tries to get it right (bubbling, mouseclick events)<br />
 * javascript waits for dynamic content<br />
 * javascript assertions</p>
<p>selenium:<br />
 * &#8220;record/playback is the root of all evil&#8221;.  none of creators wanted to do it<br />
 * next version will have more native C hooks.  javascript event faking could only get so far.<br />
 * really only good at testing in firefox, rest of browsers (including chrome) suck</p>
<p>twill:<br />
 * technically just a small DSL on top of mechanize/clientform/beautifulsoup<br />
 * forms, cookies, redirects, link checking<br />
 * but no javascript support. ever. not even a little.</p>
<p>webtest (ian bicking)<br />
 * runs fake request/responses on WSGI frameworks<br />
 * written to test paste<br />
 * doesn&#8217;t actually run http</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> myapp <span style="color: #ff7700;font-weight:bold;">import</span> wsgi_app
<span style="color: #ff7700;font-weight:bold;">from</span> webtest <span style="color: #ff7700;font-weight:bold;">import</span> TestApp
app=TestApp<span style="color: black;">&#40;</span>wsgi_app<span style="color: black;">&#41;</span>
app.<span style="color: black;">go</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/'</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> app.<span style="color: black;">resp</span></pre></div></div>

<p>nose<br />
 * nose.cfg for default cmd line opts<br />
 * &#8211;with-django plugin to help set up env</p>
<p>py.test 1.0<br />
 * distributed testing.  central reporting.<br />
    &#8211; run your tests on all different envs (clouds, o/s&#8217;s, py versions, etc)<br />
 * plugins similar to nosetests.  but not documented all that well <img src='http://www.mike-griffith.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /><br />
 * runs unittests, doctest, restdoc, pocoo (sends failures to pastebin)<br />
 * tetamap.wordpress.com, pytest.org</p>
<p>vision: make automated deployment merge w/ actual deployment, and have success<br />
be mandated for deploy.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Lightning talks<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>== argparse ==<br />
all features of optparse, but better docstrings and never touch sys.argv<br />
sub command parsers (e.g. svn add) easier than optparse<br />
mutually exclusive arguments</p>
<p>http://code.google.com/p/argparse</p>
<p>== python 3.1 ==<br />
some performance improvements.  IO now almost as fast as 2x<br />
unittest improvements.  assertRaises trick<br />
OrderedDict finally arrives</p>
<p>from __future__ import bad_syntax_ideas<br />
 * braces, no colons, no indentation, implied ruby blocks, etc.<br />
 * pep 3117</p>
<p>== Poor Man&#8217;s Continuous Integration ==<br />
try to do it without buildbot using your existing tools<br />
 * capastrano, maestro, git/svn<br />
using &#8220;fabric&#8221; instead of &#8220;git push&#8221;<br />
 $ fab push -d staging_server deploy<br />
 * wraps up the test run and git push steps</p>
<p>== cluemapper &#8211; software project manager ==<br />
example: lots of software projects<br />
 * each w/ issue tracker, svn<br />
 * want to share users across projects<br />
built on top of trac.  &#8220;trac for teams&#8221;<br />
 * basic reporting and time-tracking<br />
 * trac plugins to extend core<br />
 * wsgi + dojo ajax<br />
components<br />
 * irc bot<br />
 * theming<br />
 * pypi egg server<br />
 * bzr integration<br />
 * pastebin<br />
 * timetracking, reporting<br />
nice source control user manager for each repository<br />
roadmap<br />
 * agile/scrum/xp stories and whiteboard<br />
    &#8211; drag/drop between stories and iterations<br />
    !!!!!!!!!!!!!!!!!!!!!!! yayz !!!!!!!!!!!!!!!!!!<br />
<a href="http://cluemapper.org">cluemapper.org</a></p>
<p>== ReleaseBot ==<br />
release mgr process watches buildbot<br />
push button to tag a version for deploy<br />
 * workflow for notifying QA that this is what needs tested<br />
buildbot notices tag and preps for release<br />
not yet developed, just idea phase</p>
<p>== pyjamas ==<br />
python to javascript compiler, with built-in widget set<br />
JSONProxy seems fun!<br />
rest is pure evil.</p>
<p>== \ is evil ==<br />
don&#8217;t split lines with a backslash<br />
use parentheses instead</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">my_str = <span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;asdlfkjasdf   asdlfkjdsf&quot;</span>
        <span style="color: #483d8b;">&quot;  asdflkj   asldkjf &quot;</span>
        <span style="color: #483d8b;">&quot; alskjdf asdlkjj &quot;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>insetad of</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">evil_nasty_str = <span style="color: #483d8b;">&quot;asdlfkjasdf   asdlfkjdsf&quot;</span> \
        <span style="color: #483d8b;">&quot;  asdflkj   asldkjf &quot;</span> \
        <span style="color: #483d8b;">&quot; alskjdf asdlkjj &quot;</span></pre></div></div>

<p><strong>Mini-conclusion</strong><br />
Things for follow-up:<br />
 * windmill.  first round of experimenting at openspace didn&#8217;t prove to be as awesome as i had hoped.  but i&#8217;m willing to give it another try.  scripting these in python feels like an afterthought, and it wouldn&#8217;t be easy to get integrated with BuildBot.<br />
 * ClueMapper.  looking forward to the scrum/xp tools built into Trac.<br />
 * webtest instead of twill for scripting end-to-end tests<br />
 * py.test for distributed testing<br />
 * tokyo cabinet for key/value store with persistence<br />
 * web2py web framework.  the data schema admin manager doesn&#8217;t feel quite as polished as django, and i don&#8217;t like the online editor.  but their MVC ideas and templating implementation might be useful.<br />
 * mercurial or bzr.  i need more practice with DVCS.  i committed all my code throughout the weekend to a local mercurial instance, but never pushed up to a central repository.  </p>
<p>That&#8217;s all she wrote for now.  Looking forward to future PyCon&#8217;s and to trying out some of these awesome tools.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mike-griffith.com/blog/2009/03/notes-from-pycon-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
