[ Content | Sidebar ]

Posts tagged python

New Year’s Python meme: 2012 edition

Partially as a year-in-review kind of action, and partially to reinvigorate my writing, I thought I’d participate in Tarek Ziade’s New Year’s Python meme: 1. What’s the coolest Python application, framework or library you have discovered in 2011? Flask. Django was the only Python web framework I’d worked with until this last November, so it [...]

Unladen Swallow’s progress

One thing that caught my eye in the Euler test results is that Unladen Swallow comes in with a total time of 509.72 (seconds?) vs. CPython’s 569.37. That’s an improvement of about 10%. When you look at the wins, Unladen Swallow has 33 vs. CPython’s 51. That 5x improvement on CPython looks pretty far off. [...]

PyPy outperforming CPython and Psyco

David Ripton ran a bunch of implementations against his collection of Euler Challenge solutions: And now PyPy is clearly the fastest Python implementation for this code, with both the most wins and the lowest overall time.  Psyco is still pretty close.  Both are a bit more than twice as fast as CPython. I’d really like [...]

Compute all permutations of a string in Python

The Problem Here’s a problem I was asked recently: Write a function permute such that: permute(‘abc’) → ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'] Now, immediately this should look like a recursive problem. Put in English, we want to do the following: Iterate through the initial string – e.g., ‘abc’. For each character in the initial [...]

Django and PEP 8

If you’re looking around the source for Django, and you’re wondering why arguments that might be named ‘class’ are named ‘klass’ instead of ‘cls’ or ‘class_’ per PEP 8 guidelines (e.g. here), you might be interested to know that the recommendation against ‘klass’ didn’t fully appear in PEP 8 until December, 2005. Prior to that, [...]