Web requests in Python

Recently tried making web requests in Python.

I used the urllib2 library for making 10 requests to the Azure Machine Learning web service.

Interestingly I found that using urllib2  was incurring a lot of latency.   I replaced urllib2 with the requests libarary and boom, the latency improved tremendously.


  • it seems the requests library  by default uses KeepAlive.  As such, it was not re-initiating the connection each time for the multiple requests. urllib2 on the other hand was re-initiating the connection for each request.
  • Note:  the requests library is still making synchronous calls.

Ubuntu Terminal Smarts

I think using the Ubuntu Terminal in a smart way is crucial for day-to-day productivity.

I came across this nice link where several tricks are listed down and explained nicely.


Note: The consistent Copy-Paste mechanism  I have found working across Unity terminal, Xfce terminal, unity gvim, xfce gvim etc is  using:

  • Control + Insert : to copy
    • this is also same as ‘copy on select’ i.e. just select the text and it will be copied automatically.
  • Shift + Insert : to paste

Check it out!