Europython 2007 Day 1

Europython is upon us and I'm sitting here enjoying hotel wifi and coffee in (fairly) sunny Vilnius.

So far it's quite different to PyCon. Apart from an almost completely different set of people, I actually got to spend time chatting with Guido over a beer. Fanboy alert! ;)

Anyway, here's some notes I took on some of the talks I've sat through so far. You can view other folk's coverage of europython:

10:00 - 10:30 Pythonic Interfaces

  • Talking about class interfaces
  • Enforces interface
  • Looked at other interface libraries
    • zope.interface, pep 245, cookbook, pyprotocols
    • poorly documented and lack of examples
  • "interface" package
  • Abstract base classes
  • Very java inspired
  • PEP 3119 very similar
  • Some performance penalty, caches classes for speed
  • http://www.mikeware.com/
  • Compared to good test suite coverage?
  • Not released yet
  • Writing a PEP, will post library later?!?

11:00 - 11:30 Case Study of a Pylons Project

  • Overview of pylons and how it worked out
  • http://www.developers.org.ua/
  • Switched from php to python
  • supervisord, cherrypy, paste, pylons, postgres and mysql, apache + php for legacy stuff
  • Switched from myghty to mako
  • Took a while to figure out how to setup sqlalchemy stuff for 3 dbs in pylons
  • Use routes, minor addons to BaseController to handle i18n, db and validation errors
  • gettext and unicode for i18n
  • mako and paste encode correctly
  • authentication
    • tried authentication with authkit with no success
    • next tried paste.auth but had problems too
    • fell back to wordpress for authentication
  • forms
    • tried toscawidgets but gave up
    • used htmlfill and formencode
    • wrote validation code: validate and error decorators
  • paste.fixture for testing
  • fiddly setting up wsgi stack by hand for testing
  • deployment
    • using mod_proxy and pylons process
    • supervisor2 to monitor
    • runs staging and production copies
  • good:
    • pylons approach to project structure
    • routes, sqlalchemy, mako
    • i18n
    • wsgi
  • bad
    • documentation, had to use source
    • lack of features
    • deployment
  • pylon's is a hacker's framework
  • slow start to pylons but paying off
  • approx 2000 visitors a day

12:00 - 12:30 Tux Droid, a python-fueled robot

  • Robot controlled wirelessly from PC
  • USB dongle
  • remote control
  • buttons on head, wings
  • wing motors
  • base spinny motor
  • blinking eyes
  • microphone
  • beak motors
  • lighting eyes
  • IR receiver (for remote)
  • light sensor
  • IR LED to remote control stuff from tux
  • audio in/out
  • i2c connector
  • volume control
  • can store sounds in tux
  • 8GB flash, 512MB ram (?)
  • daemon exposes tux via tcp to application code
  • can play with tux in python shell
  • refactoring api to be more pythonic
  • fully open source, schematics, firmware
  • http://www.tuxisalive.com/

14:00 - 15:00 PyPy 1.0

  • Overview of what pypy is.

  • "I've worked on 3 implementations of new style classes, one for jython, one for python and one for pypy. Hopefully that is my last"

  • 1.0 contains a fully compliant python interpreter, a tool chain which produces C, LLVM and .net python interpreters, JIT, optimizations, CLR friendly backend for PyPy.net and taint and proxy object spaces.

  • Can mix and match features in produced interpreters

  • Needs polishing and missing some important extension modules

  • Special language features and rpython already useful

  • Performance is getting quite good, approximately 1.2x to 3x slower on average. In one case 6x slower.

  • Working on GC performance

  • JIT true trump card

  • JIT huge investment in resources, hard to evolve

  • Created a JIt generation framework (timeshifter)

  • Partial evaluation techniques to generate dynamic compiler

  • Psyco inspired

  • Of course hard to implement

  • Types in a dynamic language are a problem

  • e.g. know an operation is an addition, but of what? Makes constant folding hard

  • Solution is to "promote" run time interpreter parts to compiler parts, get information from the evaluation

  • Use other tricks like lazy allocation of objects

  • Dynamic generation process language agnostic

  • E.g. someone wrote a prolog interpreter in rpython, so get JIT for prolog

  • ia32 and ppc backengs

  • Int arithmetic optimized

  • in speed range of gcc -o0

  • In some cases, e.g. demo 63x faster than CPython!

  • "If you need exactly this example..."

  • Implemented as a transformation of the low level control flow graphs, use graph "colouring" to analyse. Timeshifting, turning run time graph into compile time graph

  • "green" - compile time value

  • "red" - run time value

  • see graph pics

  • Specialize function for given values of green values, e.g. f(x, y) becomes f_3(y) when x = 3

  • Need to handle conditional cases, .e.g code conditional on red code.

  • Also need to handle merges, where can reuse code

  • Need to catch loops

  • Can manually hint promotion:

    def f(x,y):
      x1 = hint(x, promote=True)
      return x1 * x1 + y * y
    

    First generates:

    def f_(x, y):
      switch x:
        pass
      default:
        compile_more(value=x)
    

    After called with 3:

    def f_(x, y):
      switch x:
        case 3:
          return 9 + y * y
      default:
        compile_more(value=x)
    

    Obviously works well with repeated calls with same values

15:00 - 15:30 PyPy Python Interpreter(s) Features

  • Adding new features to the interpreter

  • Integrating into different environments, e.g. clr

  • Handling calls to and from the target environment

  • Features are independent of backend, e.g. security tainting of objects

  • Transparent proxies, e.g. distribution or peristence

  • Demo of rope, behaves like a string :)

  • million char string constructs faster

  • transparent proxy of list shared between processes

  • frames shared transparently

  • e.g. remote_open("/etc/passwd").read()

  • can attach pdb to traceback of remote object

  • orthogonal persistence

  • taint object space allows you to control where objects get accessed. E.g. prevents sensitive object getting logged:

    >>> x = 3
    >>> x
    3
    >>> taint(x)
    >>> x
    ...exception...
    >>> l = [x]
    >>> l
    ...exception...
    
  • tainted object can't cross i/o barrier until untainted. But can still fully manipulate.

  • stackless

  • getting faster and faster

  • If you're not too dependent on extension modules pypy is getting very close to being able to run your application as is

  • OS threads don't work very well

16:00 - 16:30 z3c.dav – an implementation of WebDAV for Zope3

  • z3c.dav
  • Implementation of dav related RFCs.
  • DAV is built on HTTP to add content authoring operations
  • Adds features like locking and a data model
  • New HTTP verbs and responses
  • Defined new dav related interfaces and utilities in zope3
  • For each IDAVProperty dav prperty looks up utilities, looks up widget to render it, and finally adapter to get the values
  • IDAVWidgets control rendering of the property
  • z3c.dav defines basic types and interfaces
  • locking implemented via IDAVLockManager
  • Uses zope.locking
  • HTTP if-match and if-not-match headers implemented to allow clients to allow clients to access locked objects with the correct tokens
  • COPY and MOVE implemented using zope.copypasteremove
  • New status codes implemented
  • Currently working to get "litmus tests" working against dav implementation.
  • Need to reimplement dublin core adapters
  • Should be possible to backport to zope 2.x
  • Released on cheeseshop

16:30 - 17:00 unittest is Broken

  • Can't add extensions in a modular manner, can't distribute them
  • Different parts are separate (loading, running, reporting, etc) but very coupled.
  • New framework, test_harness and compose a runner from different parts
  • Bunch of extensions written already, e.g. todo, xml output, skipping, separate interpreter per test, etc
  • division of labour, different steps in test running process, each doing a discrete part
  • Why not one of the other frameworks?
  • They don't do what Collin needed, in particular ability to easily extend
  • http://oakwinter.com/code/test_harness/
  • Question of comparison with trial, how to handle deferreds? Should be possible
  • Backwards compatible with unittest
  • Don't need to organise into classes
  • Doesn't have the same test discovery sophistication of py.test or nose yet
  • Holger suggested an open space shoot out between the frameworks

17:00 - 17:30 A practical example of Test Driven Development for a GUI using wxPython

  • gui code very error prone
  • gui libraries are not unit testable
  • Use mock objects to simulate gui code
  • tools to perform acceptance testing of gui available
  • Using pmock (http://pmock.sf.net/)
  • using pywinauto for acceptance tests
  • working on sample data entry application
  • mocking view and model in tests
  • Goes through of writing test first, then code and makes test pass
  • Changes a view to a mock object
  • Sets expected call on the mock object
  • Sets return value on mock object
  • Adds and refactors tests

17:45 - 18:45 Keynote by Simon Willison

  • Talking about OpenID
  • What is OpenID
  • Covers common questions
  • JanRain provides libraries for sites
  • idproxy.net proxies yahoo! accounts, could also do google and others
  • openid.net - developer oriented
  • openidenabled.com - general site
  • vapourware announcement - want to make pylons and django request/response objects compatible
  • openid aggregators, pull info from all openid providers

Comments

No comments yet.

Post a comment

Comment posting temporarily disabled, too much spam.