Python Programming, news on the Voidspace Python Projects and all things techie.

Happy Birthday Resolver

emoticon:apple Resolver the company, and the fledgling application, is now one year old [1].

Around this time in 2005 Giles & William started work on the functional test suite so that they could build Resolver.

Originally they decided to write Resolver as a .NET application using C#. .NET is a great framework for writing professional programs. They started to search for a scripting language to embed into Resolver. The choices were between Ruby [2] and Python, and IronPython was further advanced than the Ruby alternatives.

Neither of them had used Python before, but after playing with it for a bit they realised that it could be a lot easier to write Resolver in IronPython.

In early 2006 Andrzej joined (ironically a Ruby programmer) and I joined in around April or so. More recently Christian and Jonathan have joined the team.

Resolver today is around 15 000 lines of production code (98% Python code and the rest C#) and 45 000 lines of test code [3]. We have completed over eighty user stories.

There are only two 'showstopper' missing features before we could theoretically put Resolver into the hands of (friendly) customers. These are printing and charting. We've spiked [4] these this week and could have 'first-cut' implementations in place pretty quickly.

We have just started to show Resolver to a few potential customers. We're not yet ready for beta, but we're getting some very good feedback. We're hoping to be able to do a limited beta around spring next year.

Resolver processes 'business data', and yes that tells you next to nothing. It has Python integrated into it in a very interesting way. Smile

The good news is that the board are considering the possibility of a 'community edition', free for non-commercial use. This isn't definite, and there is no timescale, but you guys could do some amazing stuff with Resolver.

[1]Actually it was in November, but hey. Smile
[2]One of IronRuby and RubyCLR is like IronPython, and the other like Python .NET. I never know which is which.
[3]A few blog entries ago I quoted 5 000 / 15 000 LOC. This was actually the amount of code when I joined Resolver. It's grown a bit since then...
[4]Spiking is writing experimental code as research into a problem. It doesn't go directly into our production code, but is the basis for later paired work.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-12-07 22:06:38 | |

Categories: ,

Basic Hints for Windows Command Line Programming

emoticon:acrobat Most new programmers who use Windows are unfamiliar with using the command line, but it can be a powerful tool. It is especially useful for writing small scripts that can accomplish complex tasks. A command line interface can even be easier to use than a crowded graphical interface. The command line is known variously as the console, the CLI or the Shell environment.

This article is a tutorial on setting up a basic command line environment. It contains a few tips and tricks specific to Python, but should be useful to anyone who wants to set-up the console.

The article covers topics like:

  • Running and using the cmd console
  • Configuring the console including QuickEdit mode
  • Setting up the PATH and PATHEXT environment variables

Please point out any errors, or things I've missed, by posting a comment.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-12-05 21:03:56 | |

Categories: , , ,

IronPython, Old Style Classes and Performance

emoticon:eyeballz Today my boss and I were running a build chasing a checkin. We'd made various minor changes, but nothing serious. Surprisingly our performance test failed. It tests that processing a moderate sized dataset takes no more than a second. On my machine it normally takes around 0.75 seconds, suddenly it was consistently taking 2.1 seconds.

We backed out our changes until we isolated the cause. One of our classes had been an old style class, and we'd made it a new style class purely out of habit.

The class is used in our 'processing pipeline', so it gets instantiated and then called quite a few times; but only in one stage of the whole operation. Changing the class to inherit from object slowed our performance test down three times. Surprised

I've reduced it to a simple test case for both Python and IronPython; to see if it's reproducible. It accesses a few instance attributes to be slightly closer to our code.

The test code for Python is :

import time

def timeItOldStyle():
    class Example:
        def __init__(self):
            self.x = None
            self.y = None
            self.z = None
        def __call__(self):
            x = self.x
            y = self.y
            z = self.z

    start = time.time()
    for i in range(100000):
    return time.time() - start

def timeItNewStyle():
    class Example(object):
        def __init__(self):
            self.x = None
            self.y = None
            self.z = None
        def __call__(self):
            x = self.x
            y = self.y
            z = self.z

    start = time.time()
    for i in range(100000):
    return time.time() - start

print 'Old Style:', timeItOldStyle()
print 'New Style:', timeItNewStyle()

For IronPython I replaced the timing code with the following (because time.time() has a resolution of 0.1 seconds and I was getting weird results with time.clock()) :

import System
start = System.DateTime.Now
total = (System.DateTime.Now - start).TotalMilliseconds / 1000

The results :

Old Stle: 0.233999967575
New Stle: 0.25

Old Stle: 0.1875
New Stle: 0.625

Under CPython old style and new style are very similar.

For IronPython, the old style classes are slightly faster than CPython. The new style classes are dramatically slower. Hmm... worth bearing in mind.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-12-04 22:19:29 | |

Categories: , ,

Python and its Basic Datatypes

emoticon:knot You can blame this entry on Ryanair and a six hour wait for a delayed plane. Ok, so most of the wait was spent playing Super Mario Kart [1], but whilst my laptop battery lasted I made a start on the tutorial I've been intending to write for ages.

It is a brief introduction to Python and its basic data-types. It covers syntax for strings, numbers, lists, dictionaries, sets and tuples. It doesn't cover the methods, just basic usage.

In the process of writing this I realised how many syntax variations there are for strings. That made it a tad longer than it could have been. Smile

At some point I may write that tutorial, but in the meantime...

[1]Which I'm still no good at (but I beat Jonathan sometimes)...

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-12-03 19:08:43 | |

Categories: ,

Motherboards, Processors and Power Supplies: Oh My!

emoticon:new_document Ok, so back to my dead computer.

I've confirmed that the power supply is dead, and the motherboard doesn't draw power from a working power supply. The standby LED does come on though.

So the power supply is definitely dead and the motherboard is probably dead... or is it the processor. Confused

Unfortunately the only way to find out is to get a new motherboard and try it. The old motherboard is an ASUS A7N8X, which is a socket A motherboard for the Athlon XP 3000+ processor it lovingly cradles.

The A7N8X must have been a popular motherboard. You can buy a new motherboard for 20 pounds, but you can pay 40 pounds or more for a secondhand A7N8X on ebay.

So I need a new socket A motherboard, except new motherboards seem to come in a variety of delicious flavours like socket 939, 754, AM2 and in fact anything except socket A. sigh

Hopefully the lazy web will come to my rescue...

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-12-03 16:07:36 | |


PyCon Talk Presentation Tools (and stuff)

emoticon:clock It's time to start preparing for the PyCon talk. We need to decide on how to prepare the slides.

I am a big fan of ReStructured Text, so S5 is looking good (and it makes good looking presentations to boot).

Bruce also looks interesting.


Bruce is really very good. Unfortunately getting it to produce an interactive demonstration with IronPython is probably out of reach for me before the conference.

S5 / Docutils produces a more immediately web friendly presentation.

Crunchy Frog is fantastic (run the demo). I wonder if it could be made to work with IronPython ? It is more aimed at creating tutorials than presentations though.

Anyone got any recommendations or comments ?

Personally I rarely find slideshows from a talk I've not been to that useful. I hope to prepare more information to go alongside the slides. Perhaps a link from each slide for those reading online.

Some of the talks look great.

With such a great lineup it is inevitable that there will be some clash of talks I'd love to go to. From the draft conference schedule :

On Friday, the Python-Dev Panel clashes with Towards and Beyond PyPy 1.0 and Writing Parsers and Compilers with PLY clashes with both the Web Frameworks Panel and IronPython: Present and futures [1].

On Saturday, Distributing your project with Python Eggs clashes with The Absolute Minimum an Open Source Developer Must Know About Intellectual Property [2].

The testing track on Sunday looks great. If the schedule doesn't change I'll only have to miss the first one, which is the least interesting from my point of view.

Whilst we're on the subject of PyPy (which we were at least vaguely...), there is an interesting note on the Psyco Homepage (See 6th August 2005).

The future of Psyco now lies in the PyPy project, which according to plan will provide a good base for a Python interpreter with better and well-integrated Psyco-like techniques as soon as 2006. (Additionally, it is not impossible that we could even derive a C extension module for CPython very similar to today's Psyco.) So stay tuned to PyPy!

From the PyPy Duesseldorf Sprint Report :

Another topic that received attention all week was the JIT (dramatic music). The architecture of the JIT has now crystallized enough to be able to split up the work into the (for mere mortals largely incomprehensible) "time shifting" front end and the (much more straightforward) code generating backends.

Samuele and Arre started the week by adding some missing pieces for things called "portals" in the front end. A portal is the part of your code that marks the entry into JIT-land. For the PyPy interpreter it is expected to be the bytecode dispatcher (or in general the main loop of an interpreter). The JIT tests now take so long that they also had time to work on translating rsocket, which is an RPython-level socket library, and using it for implementing the socket module.

Now that's why I want to go to the PyPy talk. sigh

[1]I guess I ought to go to the IronPython one... Razz
[2]I'll probably go to the one on eggs, but maybe I can send Andrzej to the other talk. Wink

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-12-03 14:55:37 | |

Categories: ,

Google, Mondrian, Python and Guido

emoticon:python Wow. Hot news.

Guido van Rossum unveiled his first Google project, Mondrian, tonight during a Python tech talk at the Google campus in Mountain View. Mondrian is a web-based code review system built on top of a Perforce and BigTable backend with a Python-powered front-end. Mondrian is a pretty impressive system and is currently in use across Google.

News from Niall Kennedy's Weblog. Smile

So Guido is earning his pay-check at google building a web-based code review system with Python... Cool. It is backended with Perforce. Niall Kennedy's blog entry suggests that google could open source it once they have provided Subversion and SQLite backends.

From my point of view pair programming and collective code ownership beats code review, but maybe they're not mutually exclusive.

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-12-02 21:41:00 | |


Nested Lambda Fun

emoticon:clock At work we did a partial implementation of the Python grammar using PLY (for reasons which will become obvious at some point in the future if you continue to read this blog).

Because of this I knew it was possible to nest lambdas, I'd just never tried it.

Muharem Hrnjadovic has just posted about his problems with functools.partial and Because is a built-in function, it doesn't take keyword arguments, so he can't use partial to fill in the second argument.

Whilst this doesn't invalidate his general point, you can achieve his specific aim with a nested lambda. Shown is a function (lessthansomething) which takes an argument (something). It returns a function which takes an argument and returns True if the argument is less than something. All in a oneliner Smile

Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> lessthansomething = lambda something : lambda x : x < something
>>> lessthansomething
<function <lambda> at 0x00B43270>
>>> lessthan3 = lessthansomething(3)
>>> lessthan3
<function <lambda> at 0x009E9AB0>
>>> lessthan3(2)
>>> lessthansomething(6)(7)

Don't do this at home [1], but it's still fun.

[1]Or more to the point, don't do it at work...

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-12-02 21:09:19 | |

Categories: ,

Earliest Known Pythoneers and the Real Meaning of Pythonic

emoticon:pda It has just been discovered that there have avid Pythoneers around for about 70 000 years.

Pythoneers from 70 000 years ago.

Additionally, according to Webster's Revised Unabridged Dictionary 1913 edition, "Pythonic" means "Prophetic":

Py*thon"ic (?), a. [L. pythonicus, Gr. . See Pythian.] Prophetic;
oracular; pretending to foretell events.

(Which apparently comes from Greek mythology and the oracle at Delphi.)

All taken (with a large pinch of salt) from the folks at Python-Dev. Smile

Like this post? Digg it or it.

Posted by Fuzzyman on 2006-12-02 20:23:55 | |

Categories: ,

Hosted by Webfaction