Older blog entries for jdahlin (starting at number 13)

Yesterday I got inspired by the performance work federico posted. I decided to take a look on why gnome_vfs_get_volume_monitor() was so slow. After some investigation, a few modifications (adding colors and crude execve support) to the nice pycairo script federico wrote to plot strace logs and adding some markers to bonobo-activation, I came up with the following plot:

The python script I used to test can be found here.

Just before running this I did the tail /dev/zero trick (with swap turned off) to "flush" the kernel cache.

As the graph quite clearly states, bonobo-activation-server is spending about one second listing directories, reading and parsing .server (xml) files. The gconfd-2 startup is probably not so bad (it used to be a lot worse), but I do wonder why it takes so long time to import gnomevfs.

When can we have DTrace for Linux?

18 May 2005 (updated 18 May 2005 at 12:49 UTC) »
Introspection
Been working quite a bit lately to get the new GObject introspection going. Spent too much time hunting various memory corruptions, but I finally managed to get to a point where I can do the following:

  import bank
  import Poppler
  doc = Poppler.Document('test.pdf', '')
  pages = doc.getNPages()
  print 'Document has', pages, 'pages.'

which prints out:

  Document has 247 pages.

The Poppler module is built completely from the introspection information, the Document class and all its methods are created in runtime (not lazily yet though). The constructor maps to a C function, poppler_document_new_from_file which is invoked in runtime, with help of libffi, the reference is saved and sent to getNPages which calls poppler_document_get_n_pages.

Poppler is a pdf library, which I used as a testcase because that's the only library available which has introspection information written down, all thanks to jrb.

This stuff looks really good, it's a bit more complex then manually created bindings for python, but once it's finish it'll be a lot less work. We anticipate that the python bindings, in which most of the work can be done in runtime, will be dramatically reduced, perhaps to 20-25% of the size it has today.

If you're interested to look at this stuff, it can be found in the pybank module in gnome cvs.
There is not a lot too see yet though, unless you're also developing a language binding

J5: that looks very similar to deferreds, found in twisted.
Although in a twisted world with deferreds you don't really need to specify the return type as you did in your example.

Perhaps it's worth designing the python bindings after features found in recent python versions such as generators and decorators, which wingo wrote about a couple of days ago. You might also want to take a look at xmlrpclib, which is very easy to use, thanks to excessive getattr usage. Not sure if you want to walk down that road for D-BUS, but it's definitely worth looking at.

7 Jan 2005 (updated 7 Jan 2005 at 19:51 UTC) »
PyGTK
Lot's of things happening here.
We had a great Mega BOF at MatarĂ³, most of the developers participated, we even got John to fly in from Boston for the meeting! Plenty of things discussed, we know have a better idea of what needs to be improved and what we're going to do over the next few months.
GNOME 2.10 feature freeze is just around the corner. I have a big patch from Gustavo to merge to be able to implement virtual methods. Once they're in we can finally subclass GtkContainer and GtkCellRenderer properly. And with just a little more work interfaces should be implementable as well.
On the application side it seems like the next version of Bittorrent will use PyGTK. The ui looks a lot nicer, but still has some issues (resizing, no file chooser). The cool thing is that it's also used on win32, which means our user base will increase by millions.

Life
December went by very quickly. Travelled a lot, from Ulricehamn in the country side of Sweden to Rio de Janeiro for Christmas. Finally settled down in Brazil. It's great to be back here, even I haven't realized how much I missed things here. But not for too long, a trip to Asia is not far on the horizon.

  • Fluendo
    Today is my last day for Fluendo. It's been a great year, doing tons of interesting stuff and learning even more. But great things always comes to an end. I owe some people here a big thank for believing in me and giving me a chance to work here. I'm sure I'll miss Thomas, Wim, Christian and Julien.
    Thank you guys.

  • Ubuntu conference
    I'll attend the major part of the Ubuntu conference, in Mataro, just outside of Barcelona. We're going to have a big PyGTK BOF and almost all active developers are going to be present. It'll be a great to meet everybody in person. I did a PyGTK 2.5.0 release the other day, so now people can start using the new goodies from the Gtk+ development branch. John Finlay already has an updated reference manual.

  • Seamless
    Martin Soto finally, by doing a nigera scam, released his DVD player, which is using gstreamer and python. Really fun to see people using gst-python for application. It's the missing glue for applications. We were particulary impressed by the design choice to do have the DVD virtual machine implemented in python. We didn't have any movies in the office, so I had to resort to other things for testing. The Buffy DVDs thomas had worked flamelessly with subtitles, synchronized audio/video, fullscreen and fast seeking.

  • Advogato
    I'm your master.

  • Brazil
    If I can sort my visa out, I'll be there before Christmas. Can't wait.

25 Oct 2004 (updated 25 Oct 2004 at 23:58 UTC) »

I wrote a small GConf directory wrapper using a type and GObject properties. Using this you can just select a gconf directory and then modify the properties using the standard set/get accessors from GObject:

>>> obj = watch_directory('/apps/metacity/general)
>>> obj.get_property('theme')
'Metabox'

notify:: if you want to get notification if any/some properties changes. In Python, all it takes to get notifications for a directory is this:

>>> def notify_cb(obj, pspec):
...   print obj, pspec.name, obj.get_property(pspec.name)
...
>>> obj.connect('notify', notify_cb)
As jamesh points out, I should probably separate the type creation and instantiation of the object, so it can be possible to point the type against a schema directory and instantiate over several different configuration directories.

The code can be found here, unfortunately it requires gconf from gnome-python CVS HEAD, due to some missing functions. If there is enough interest I might port this to C, because I think it would be useful to have it, in for example GConf itself.

Gtk+/Gnome python bindings

Released PyGTK 2.4.0, gnome-python 2.6.0 and PyORBit 2.0.1. This marks a major milestone for the Gtk+ and Gnome python bindings.

PyGTK now supports all the beauties of GtkUIManager and GtkFileChooser. So start updating your code!

Over the last few days I've been writing bindings for the "new" nautilus extension API introduced a while ago. It can be checked out from gnome cvs, the module name is nautilus-python. I'd say that its a lot nicer than the old bonobo/corba based one. I also wrote a couple of examples, which can be found here I specially like the "Use as background image" context menu plugin. I wonder if we're going to see a new g-scripts site now..

27 Sep 2004 (updated 27 Sep 2004 at 21:53 UTC) »

Clarkbw (via planet): If you want to count lines, use this instead:

pipeline = gst.parse_launch('{ cdparanoia ! osssink }')
pipeline.connect('eos', lambda p: gst.main_quit())
pipeline.set_state(gst.STATE_PLAYING)
gst.main()

The beauty of abstracting things away...

  • Gst-Python

    Great progress recently, you can do most normal things and some not so common. The GstPlay class is wrapped, so now can actually write a simple movie player in just 8 lines of code:

    import sys, gst, gst.play
    play = gst.play.Play()
    play.set_data_src(gst.Element('filesrc'))
    play.set_audio_sink(gst.Element('osssink'))
    play.set_video_sink(gst.Element('xvimagesink'))
    play.set_location(sys.argv[1])
    play.set_state(gst.STATE_PLAYING)
    gst.main()
    

    If you have gst-ffmpeg installed, this is enough to play mpegs, avis, qts etc.

    Hope I'll be able to do a release within the next couple of days.

  • PyGtk

    2.2.0 was released the other week, lots of good stuff done recently by Xordoquy, Gustavo, Christian and Lorenzo. Feels like we finally have a bunch of stable developers. Some work to merge in the new widgets from Gtk+ 2.4 has already started. Hopefully it won't take another 6 months be fore PyGTK 2.4.0 can be released.Note that the three links for setting the source and sinks will probably go away as soon as I wrap the GConf stuff.

  • Barcelona

    15-18 degrees and sun strongly shining sun for the last couple of days. I'm certainly not complaining.

27 Jan 2004 (updated 27 Jan 2004 at 22:04 UTC) »

4 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!