Python Programming, news on the Voidspace Python Projects and all things techie.
Python Magazine and On Your Desktop
The Python Magazine has launched! The first is in electronic format (pdf) and is free.
Interesting articles on concurrency, WSGI and PyGTK amongst other things.
Steve Holden, along with the many other hats he wears, runs a new blog called On Your Desktop. This features entries from members of the Python community on their desktops (virtual, real and beyond)...
The latest entry is from me.
In totally unrelated news, my favourite (Windows only) CD/DVD burning tool has done a completely new release (after a long break): CDBurnerXP.
Max Recursion Limit in CPython and IronPython
Until recently Resolver had a bug regarding infinite recursion in user code. Of course infinite recursion is generally a bad idea, but it happens to the best of us sometimes.
Python has a way to control the maximum depth of recursion before you see: RuntimeError: maximum recursion depth exceeded, through sys.setrecursionlimit(x) (for some sensible value of x). For CPython on Windows the default limit is 1000, not terribly generous but usually more than enough.
On IronPython the value is unset, or more to the point is set to sys.maxint:
This is too much for the underlying .NET platform, and the result of a recursive function is:
Slightly odder is what happens when you set high(ish) values for the recursion limit. In general IronPython is faster than CPython for recursion as it has much lower overhead for function calls. For both CPython and IronPython a recursion limit of 1000 means that infinite recursion terminates in the blink of an eye.
In CPython the same thing happens with a higher limit, say 5000. For IronPython this takes around ten seconds before it terminates.
The default value needs to be lower for IronPython, but something odd is going on for the deeper levels of recursion.
It turns out that the default recursion limit of sys.maxint is deliberate, and means "don't handle stack overflow at all". This is because there is a performance overhead (involving access to a thread static variable - which is slow in .NET) in monitoring the Python stack frames.
Interestingly, we did a performance comparison on some code that used a thread local today with Resolver. On a twin core machine there was no difference, but on a single core machine it caused a measurable hit.
Dino agrees that the slowdown for recovering from deep recursion is odd, and although it is probably related to percolating the exception back up the stack (catching and rethrowing) it is still excessive and he will look into it.
Non Gadget Cooking Gadget
Well, I don't often do this, but this is a review of some cooking equipment I got sent because I blog from time to time about gadgets! Now my wife is normally the one who cooks, so this is based on her experiences.
This is the Jamie Oliver Survival Kit, made by Tefal. It counts (sort of) as a gadget because it is a set of pans (including saucepan, frying pan and wok) that all pack away together into a small space with their lids. Great for taking camping or for surviving in a post-nuclear holocaust.
They look attractive, but even better Delia was extremely impressed when she gave them a road test. They are a versatile set of pans, with a non-stick surface that claims to cope with metal implements and so far has lived up to that claim. Delia's favourite is the wok.
They feel heavy and substantial, which is good for non-stick stuff which is usually very light and tends to wobble around the kitchen. These are nice and stable.
They can all go in the oven at a high temperature and in the fridge.
Nothing burned in them (which just means that Delia is a good cook right? But she says that it means the heat was distributed evenly).
The saucepan can also be used to grill with.
The pans have one detachable handle that is shared between them all. At first Delia was worried about whether this would last, but like the pans it feels like a well made mechanism and makes it easier to serve from the pans.
Really Delia didn't have anything negative to say about them, except perhaps that they are quite expensive.
They are running a Hack the Kit competition, where they're asking for people to come up with hack suggestions for the Survival Kit. The best suggestions will be made into a hack video, and the best idea will win a 'super nifty electric scooter'.
New Resolver Screencast
One of the brains behind Resolver is Robert Smithson. He's one of the directors and we call him our 'wild eyed visionary' - every startup needs one of those. He works in the finance industry and is well acquainted with creating and maintaining monster spreadsheets.
He's been experimenting with creating screencasts of Resolver. This is his first (he apologises for it being a wmv file - an accident of history):
He goes through creating a spreadsheet to analyse and predict election results (for the UK), and then turns this into a web application. The whole screencast is about 14minutes and it includes using a simple function to simplify what would otherwise be complex formulae, and creating a simple web application for predicting results. This example is motivated by his father's Political Betting Site.
Before slashdot, Giles' Web Application in 10 Minutes with Resolver screencast had been watched by a few hundred people. According to the logs it has now been watched by around 6000 (the Slashdot article pointed people to Jon Udell's screencast first - so his will have been watched even more). Great fun.
IronPython in Action: Chapters 5 and 6 Available
Chapters five and six of "IronPython in Action" have just become available via the Manning Early Access Program:
The chapters available are 'only-slightly-edited', so they will be further edited before publication but are basically ready.
These two chapters complete the example application and explore reading and writing XML, first class functions (including decorators), the observer pattern, properties, dialogs, serialization with the BinaryFormatter and using IronPython with Visual Studio Express.
I'm most of the way through the chapter on testing (I still have to decide how much to write on functional testing) after which the book goes deeper into Python and how IronPython interacts with the Common Language Runtime. The rest of the book is more recipe focused than the first few chapters, but will still be good.
The Men of Iron Podcast
Craig Murphy has just posted a podcast he recorded with me at Mix UK about IronPython and the Dynamic Language Runtime. It includes an interview with a developer called Dave Verwer talking about IronRuby.
The podcast is 25 minutes long, and starts with the interview with me. I sound very nervous at the start (I don't remember being that nervous, Craig is very easy to talk to!) but is generally pretty good. Uhm, one minor thing though. When I say I work for a small silverlight I mean that I work for a small startup. Oops!
Swap Parameters Script for Vim
My colleague Kamil Dworakowski has just done a blog entry with a Vim script for swapping function and method parameters:
Even though I find Vim painful, this script is pretty useful. It should also be easy to port to Wing (my IDE of choice) which has just seen the release of version 3.0. Congratulations to the Wingware guys.
This work is licensed under a Creative Commons Attribution-Share Alike 2.0 License.