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

Ironclad 0.1 Released: C Extensions for IronPython

emoticon:firefox Python 2.5.2 [1] has just been released, but more importantly the work at Resolver Systems on C Extensions for IronPython has finally born fruit:

William Reade (who has done most of the work) posted the following along with the announcement:

It's not very impressive yet, and it's still win32-only, but it will import the bz2.pyd module from CPython 2.5; the compress() and decompress() functions should work, as should the BZ2Compressor and BZ2Decompressor types. Sadly, BZ2File still needs quite a lot of work. Nonetheless, please download it and have a play. Very Happy

Be aware that you can't just reference the DLLs and have everything Just Work -- have a look in 'tests/' to see how to make it work; have a look at 'doc/details.txt' if you're interested in what's going on under the hood.

Bug reports, complaints, advice and patches are all very welcome; of course, bug reports with integrated patches and test cases will receive the maximum possible brownie points. Wink

The repository includes a description of the requirements and how to build Ironclad, plus a description of how it works. Despite William's protestations it is really very impressive. There is still a lot to do (a lot of the CPython API still to implement!), but it is already well beyond proof of concept.

Other Python news have made Python their programming language of 2007:

Congratulations! It's my pleasure to inform you that Python has been selected as the Programming Language of the Year in the 2007 Members Choice Awards. For more information, visit:

Python got 21.8%, followed by C++ and then C / PHP (then Java, Perl, Ruby, C#, Lisp and Haskell). It will distress many die-hards (and perhaps a few new-hards) that C# came in ahead of both Lisp and Haskell, but then it could be a conspiracy... Wink

[1]2.5.3 should be released in around 6 months, or shortly after 2.6 final (whatever happens earlier). 2.5.3 is likely to be the last release of Python 2.5. The schedule is for alphas of both Python 2.6 and 3.0 to be released on Friday, February 29 (prior to PyCon).

Like this post? Digg it or it.

Posted by Fuzzyman on 2008-02-22 21:12:59 | |

Categories: , , Tags: , ,

Catchup plus More Mac Musings

emoticon:scanner Sorry for the lack of posts, I've been playing catchup. I've just finished the first draft of a 4000 word article on ConfigObj for the Python Magazine. I've also done a 500 word article on IronPython for the MSDN Flash UK newsletter. Ironically the 500 word article (on a whole programming language) is slightly under the word limit, the 4000 word article (on a module for handling configuration files) is slightly over the word limit... Don't worry I'll be sure to let you know when they're both available to read. Very Happy

After the 1.0 release, we've been working hard over at Resolver Systems. We've been working on 1.0.1 which should be released any day now. For this release we've focussed on usability defect fixes and have managed to close out all the ones we scheduled plus a few extra (and one or two new features and performance enhancements along the way). We're still deciding what major features to work on for version 1.1, but whilst the boss is making his mind up we've been focussing on improving the speed of importing spreadsheets from Excel, improving recalc speed and reducing memory use.

Several people responded to my last blog entry with links to Mac OS X clients for Subversion. It looks like there are plenty! None of them are quite as good as TortoiseSVN for Windows (which sets the bar pretty high), but I'm getting used to the command line. Smile

One of the major failings of the Mac OS X interface is that application menu bars appear at the top of your first monitor. If you have multiple monitors this puts the menu for applications a long way away. The best way round this I have found so far is a combination of DejaMenu (freeware) which brings up a context menu with a keyboard shortcut and Steermouse ($20 shareware) that can assign keyboard shorcuts to mouse buttons! Hardly ideal. Surprised

Oh, and one final thing - another Python snippet. This one discovered by Andrew Dalke as he pokes around in the dusty corners of Python's grammar:

>>> def eggs((a, )=2.1):
...   pass
>>> eggs()
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "<stdin>", line 1, in eggs
TypeError: 'float' object is not iterable

Using tuple unpacking in the function signature (which will disappear in Python 3) it is possible to create default arguments in functions that raise exceptions when you try to use them!

Like this post? Digg it or it.

Posted by Fuzzyman on 2008-02-21 23:38:18 | |

Categories: , , Tags:

Silly Snippets

emoticon:envelope Here are some fun snippets of Python, which may or may not do what you expect.

>>> isinstance(type, object)
>>> isinstance(object, type)

This really just illustrates Python's object orientation. Everything in Python is an object (is an instance of an object), this includes type since types are first class objects. object itself is a type - so it is an instance of type.

>>> 3 is not False
>>> 3 is (not False)

Just illustrating that sometimes all is not as it appears with identity checks. (I assume that is and not are both tokens to the lexer but that is and is not are actually different operators to the parser.)

class S:
    def __del__(self):
        print e.args

e = BaseException(1, S())
e.__init__("hello")   # segfault

This is an interesting one posted to Python-dev recently and actually reveals a subtle bug in the way Python uses reference counting to do garbage collection. It is pretty pathological though. When the 'decref' happens the finalizer (__del__) is called - which can sometimes find a route back to the now invalid object. There is a really interesting post on Python garbage collection over on the PyPy blog: PyPy Development: Python Finalizers Semantics, Part 1.

>>> class T(type):
...  def mro(self):
...   return []
>>> class C: __metaclass__ = T
>>> class D(object):
...  pass
>>> d = D()
>>> d.__class__ = C
>>> isinstance(d, object)

This is silliness from Michael Hudson. He says that the primary use case is for looking geeky on IRC. Actually lying to isinstance can be useful when creating proxy classes (but you can't lie to checks that use type(something)).

Back to Mac stuff. SCPlugin is nothing like as good as TortoiseSVN (yet - it is a younger project), but dropping down to the command line is kind of reassuring. I've discovered that Parallels can be made to work with multiple monitors (it basically fakes a single display the combined width of your Mac desktop - but it works fine). Looking for a straightforward IRC client for the Mac - so far Colloquy seems fine other than its unhelpful error reporting. The most useful little application I've found is OpenTerminalHere. It puts an icon on finder windows that opens a terminal window with the current directory set to the directory you are viewing (kind of like 'command window here' on Windows).

Like this post? Digg it or it.

Posted by Fuzzyman on 2008-02-18 20:34:52 | |

Categories: , , Tags:

More Pyglet and OpenGL

emoticon:music Today I've been switching my desktop environment over to the Mac. I've also moved all my important files into a subversion repository, which makes switching easier. This is the first blog entry on the Mac, but it doesn't count because wxPython crashes on Leopard and I'm running Firedrop under Parallels.

Anyway, all that has nothing to do with this blog entry. Smile

Jonathan Hartley has been furthering his Pyglet exploration.

The tart plays with Pyglet

Co-incidentally, Sylvain Hellegouarch has also posted some examples of working with OpenGL, from IronPython, to the IronPython Cookbook:

These examples use the Tao Framework which is a classic example of a project where their about page tells you nothing about the project...

Back to the Mac. Mac OS X binaries for the latest version of Mono (1.2.6) includes a prebuilt MonoDevelop. Unfortunately it isn't at all usable on Leopard. On my MacBook Pro it won't compile a trivial projects and mangles lines as you edit. On my Mac Pro it wouldn't even launch. Oh well, early days I guess. I also experimented with VMware Fusion as it supports 64bit operating systems. Unfortunately it doesn't support 64 bit bootcamp partitions and as I have paid for Parallels I'll stick with it for now.

Like this post? Digg it or it.

Posted by Fuzzyman on 2008-02-16 23:27:40 | |

Categories: , , Tags: , , ,

Hosted by Webfaction