Archive for the 'Django' Category

Holy Shmoly, Ruby 1.9 smokes Python away!

Antonio Cangiano November 28th, 2007

Alright the title of this post is a tad sensational sounding, I know, and it’s in part aimed at messing with my many Pythonista friends. We Rubyists have been teased for a long time, due to the slowness of the main Ruby interpreter. Well, it looks like with Ruby 1.9, it’ll be payback time. Just out of curiosity I decided to run a single benchmark (you can hardly call it that) to see how Ruby 1.9 had improved over the current stable version (1.8.6). I wasn’t planning to make a post about it. It was one of those tests that you do at 3 AM in an irb session when you feel you’ve made your daily peace with your actual workload for the night. When I saw the results though, my jaw dropped. I had to blog about this one.

I ran a recursive Fibonacci function, just to stress test a bit of recursion and method calling, and while I was at it, I decided to compare it with Python too. The test was run on Mac OS X 10.5 with my MacBook Pro (Core 2 Duo 2.2 GHz and 2 GB of memory). It’s a single test (which is obviously not a real world example, as you would use an iterative version of the function if it were), and unlike with real programs, it doesn’t stress many features of the language. At least for now, there is no reasonable evidence to conclude that Ruby 1.9 - which will be released for this coming Christmas - will actually be faster than Python 2.5.1 in the majority of situations, but hear me out and check out these very surprising results.

The Ruby code:

def fib(n)
  if n == 0 || n == 1
    n
  else
    fib(n-1) + fib(n-2)
  end
end

36.times do |i|
  puts "n=#{i} => #{fib(i)}"
end

And the Python equivalent:

def fib(n):
   if n == 0 or n == 1:
      return n
   else:
      return fib(n-1) + fib(n-2)

for i in range(36):
    print "n=%d => %d" % (i, fib(i))

Running the snippets above, I got the following results:

Ruby 1.8.6:       158.869s
Python 2.5.1:      31.507s
Ruby 1.9.0:        11.934s

Ehm, hold on a second! Did Ruby just go from 159 seconds down to 12? Koichi Sasada, do you have an Amazon Wishlist? I was expecting a decent improvement, as I’ve been playing with 1.9 every now and then for a long time - so I knew it was faster - but I was blown away when I timed the latest version from trunk (even if it’s a really silly example that’s being tested). Granted Python is not the fastest language out there, but Ruby 1.9 was still able to execute the script almost 3 times as fast. It’s unbelievable.

Now it’ll be very interesting to run a series of algorithmically equivalent tests for Ruby and Python, and to see just when exactly Ruby 1.9 manages to knock Python out of the water - and where Python has still the edge. If I manage to find some time, I will report the results in this blog. But for now, I’ll say just… wow!

Ruby, Python, Haskell and Objective-C Feed Survey

Antonio Cangiano November 27th, 2007

Having little time to follow the blogosphere and its crazy rhythms of publication is not a good enough excuse for not being up to date. This rings particularly true for me as a technical evangelist at IBM, and as someone who is deeply passionate about the development and the information technology world. The biggest challenge is to quickly and efficiently divide the wheat from the chaff or, in other words, filter out the noise from the overload of signals put out there. For me, feed readers are life savers, I couldn’t cope without them.

I recently adopted a setup that seems to be working particularly well. I purchased NetNewsWire for my Mac and FeedDemon for Windows, and automatically got a one-year subscription to the online premium service from the fine folks at newsgator. The two programs are a joy to use, especially for handling very large group of feeds in a short amount of time, as I often need to do. Each program automatically synchronizes with the newsgator service, therefore no matter which computer I’m using, I’m always dealing with the same folders, subscripted feeds and saved clipping. Sure, there are free services out there like Google Reader or Bloglines, but to me there is no comparison between the experience that I have when using a sluggish web interface and a rock solid, well designed desktop application. If I have the option, I’ll always choose the latter, especially since newsgator allows me to take advantage of a centralized repository of feeds from my desktop programs, just like as if I were using their online service through Firefox. For a few dollars, I got a setup that is working awesomely well for me and it’s saving me huge amounts of time. It also helped me to identify non-updated blogs, and those that I was no longer paying attention to, therein allowing me to reduce my over-all amount of feeds (granted with a conscious effort on my part) to a more manageable total of 160.

As mentioned above, my subscribed feeds are important to me, with a list that changes dynamically over time, as I add and remove entries. That said, I was looking at my Ruby and Rails folder when I decided to share my feeds with you. The list is understandably incomplete (after all, there are thousands of Ruby related blogs) and the presence of planets, aggregators and tags in bookmark services like del.icio.us, generate a few unavoidable duplicates. These are the Ruby/Rails blogs and sites that I currently subscribe to:

  1. alternateidea.com
  2. antoniocangiano.com
  3. blog.codahale.com
  4. blog.fallingsnow.net
  5. blog.grayproductions.net
  6. blog.innerewut.de
  7. blog.jayfields.com
  8. blog.leetsoft.com
  9. blog.segment7.net
  10. blog.talbott.ws
  11. blog.zenspider.com
  12. blogs.thoughtworks.com
  13. brainspl.at
  14. chneukirchen.org/blog
  15. dablog.rubypal.com
  16. db2onrails.com
  17. del.icio.us/popular/rails
  18. del.icio.us/popular/ruby
  19. demo.mephistoblog.com
  20. drnicwilliams.com
  21. eigenclass.org
  22. eli.thegreenplace.net
  23. errtheblog.com
  24. glu.ttono.us
  25. groups.google.ca/group/comp.lang.ruby
  26. groups.google.ca/group/rubyonrails-talk
  27. headius.blogspot.com
  28. hivelogic.com
  29. intertwingly.net/blog
  30. memeagora.blogspot.com
  31. metaatem.ne
  32. mir.aculo.us
  33. ntschutta.com/jat
  34. nubyonrails.com
  35. ola-bini.blogspot.com
  36. on-ruby.blogspot.com
  37. onestepback.org/index.cgi
  38. peepcode.com/products
  39. planetruby.0×42.net
  40. pragdave.blogs.pragprog.com/pragdave
  41. rubyblogs.org
  42. rubyforge.org
  43. ryandaigle.com
  44. tomcopeland.blogs.com/juniordeveloper
  45. twsummary.blogspot.com
  46. weblog.jamisbuck.org
  47. weblog.rubyonrails.com
  48. www.adaruby.com
  49. artima.com/buzz/community.jsp?forum=123
  50. chadfowler.com
  51. clarkware.com/cgi/blosxom
  52. cornetdesign.com
  53. danwebb.net
  54. igvita.com/blog
  55. jroller.com/obie
  56. juixe.com/techknow
  57. loudthinking.com
  58. oreillynet.com/ruby/blog
  59. pjhyett.com
  60. quotedprintable.com
  61. railscasts.com
  62. railsenvy.com
  63. robbyonrails.com
  64. rubyinside.com
  65. rubyonrailsblog.com
  66. rubyquiz.com
  67. slash7.com
  68. softiesonrails.com
  69. technorati.com/tag/ruby
  70. technorati.com/tag/rails
  71. therailsway.com
  72. urbanhonking.com/ideasfordozens

You can download the file Ruby-Rails.opml to easily import all of the above feeds into your own reader.

Since I’m sure there are plenty of other “must have” Ruby feeds and blogs that are not currently on my radar (no word of a lie, I’ve already added more since I put the list together), I openly invite you to write a small entry in your blog as well, and show us what feeds you subscribe to. Please link back to this original post, or I won’t be able to easily find your answer. Consider it a sort of Ruby and Rails feed survey.

And since we’re on the topic, and the amount of feeds that I follow is dramatically reduced now, I’d like to extend an invite for you to do the same thing with Python/Django, Haskell, and Objective-C, assuming you are into any of these communities respectively. Those are the languages that interest me the most and I’d like to start following a good selection of feeds on these topics. If you don’t wish to blog about it, or use the comment section below, you can always write me privately at acangianoATgmail.com, specifying if you are okay with me crediting your list to you. I’d like to collect and organize the most interesting ones in a “results” type of post.

I thank you in advance, as I think it’s an interesting “experiment” that can be quite useful, especially for those who are just starting to learn any of the languages above.

IBM’s Python and DB2 drivers released

Antonio Cangiano October 29th, 2007

I’m glad to inform you that the beta version of the Python and DB2 (IBM databases to be more exact) driver and DBI wrapper have been released in the Python Package Index. You can download the source for version 0.1.0 from here. This includes two components:

  • An IBM defined API based driver to access IBM databases (entirely similar to the Ruby and PHP ones)
  • A Python DBI based wrapper to access IBM databases

The DBI wrapper utilizes the IBM defined API driver, but you can also use the feature-rich API indipendently without the DBI wrapper.

I plan to provide a few examples about the usage of the IBM specific API. The Python driver is almost identical to the Ruby one, hence I may create a joined post for both languages. Now go try it and have fun. If you have any questions, feel free to comment below or send an email to the address opendev@us.ibm.com.

« Prev - Next »