Posts

Showing posts with the label python

Technical Goals for 2011: Mid Year Review

Although we are already 2 months past the middle of the year, I decided to do a "mid year" review of my technical goals for this year to see how am I doing. Here we go: HAML, SAAS & Coffeescript : No progress :( SproutCore & BackBone.js : After a cursory look, I decided to explore Backbone.js for our upcoming project at Pothi.com. Still getting a feel of it. Learn Haskell : Deferred Git : Since Drupal moved to Git, it is hard to ignore it and I am beginning to get familiar with it. But given that we use trac, I don't think we will be leaving SVN anytime soon. Android : No progress SQL : Finally starting to dig into this. Not a very planned effort but in 6 months managed to understand few more nut and bolts of Mysql. Ran a few Explains finally :). Learnt to generate slow queries log and also managed to fix some obnoxious queries sitting in Ubercart. Beautiful Code : I realized that "finishing" beautiful code is not the right way to appr...

Python - A good introductory programming language?

First a little experiment. The other day, I needed to count words in a string. One straightforward method for this is to break the string into tokens and count them: def count_words_split(sen): return len(sen.split()) This is nice since split automatically takes care of multiple consecutive spaces if present. However in my case all the words were guaranteed to be separated by 1 space only. So following should get the job done with a little less work: def count_words_count(sen): return sen.count(' ') + 1 This is essentially a single pass over the string with no need to create an intermediate list of strings and so should run faster. Surprisingly, on Python 2.5, the first method is twice as fast as the second one. I have no idea why. However sanity is restored on Python 2.6 and the second version is not only faster but also gets better with increasing size of input. This got me thinking about a good introductory programming language. I learned programming with C and ...